mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
Merge topic 'parse-large-int' into release-3.24
8fc822e13afile: Avoid strange istringstream crash in cmake.org binaries on Alpine Linux31f158e4c8cmStringAlgorithms: Add functions to parse strings to long long integers Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7698
This commit is contained in:
@@ -200,13 +200,19 @@ bool HandleReadCommand(std::vector<std::string> const& args,
|
||||
// is there a limit?
|
||||
std::string::size_type sizeLimit = std::string::npos;
|
||||
if (!arguments.Limit.empty()) {
|
||||
std::istringstream(arguments.Limit) >> sizeLimit;
|
||||
unsigned long long limit;
|
||||
if (cmStrToULongLong(arguments.Limit, &limit)) {
|
||||
sizeLimit = static_cast<std::string::size_type>(limit);
|
||||
}
|
||||
}
|
||||
|
||||
// is there an offset?
|
||||
cmsys::ifstream::off_type offset = 0;
|
||||
if (!arguments.Offset.empty()) {
|
||||
std::istringstream(arguments.Offset) >> offset;
|
||||
long long off;
|
||||
if (cmStrToLongLong(arguments.Offset, &off)) {
|
||||
offset = static_cast<cmsys::ifstream::off_type>(off);
|
||||
}
|
||||
}
|
||||
|
||||
file.seekg(offset, std::ios::beg); // explicit ios::beg for IBM VisualAge 6
|
||||
|
||||
Reference in New Issue
Block a user