Commit 6c88e16a authored by David E. DeMarle's avatar David E. DeMarle

replace atoi for seek because atoi can get overflow easily

With this we at least get full unsigned int range and a warning
if we overflow.
parent e941db22
......@@ -384,7 +384,12 @@ XdmfCoreItemFactory::generateHeavyDataControllers(const std::map<std::string, st
std::map<std::string, std::string>::const_iterator seekIter =
itemProperties.find("Seek");
if(seekIter != itemProperties.end()) {
seek = std::atoi(seekIter->second.c_str());
unsigned long long lseek = strtoull(seekIter->second.c_str(), NULL, 0);
seek = static_cast<unsigned int>(lseek);
if (static_cast<unsigned long long>(seek) != lseek) {
XdmfError::message(XdmfError::FATAL,
"Seek offset is too large for unsigned int");
}
}
const std::string binaryPath = getFullHeavyDataPath(contentVals[contentIndex],
......@@ -429,7 +434,13 @@ XdmfCoreItemFactory::generateHeavyDataControllers(const std::map<std::string, st
}
if (dataspaceVector.size() == 5) {
seek = atoi(dataspaceVector[0].c_str());
unsigned long long lseek = strtoull
(dataspaceVector[0].c_str(), NULL, 0);
seek = static_cast<unsigned int>(lseek);
if (static_cast<unsigned long long>(seek) != lseek) {
XdmfError::message(XdmfError::FATAL,
"Seek offset is too large for unsigned int");
}
dimtokens = boost::tokenizer<>(dataspaceVector[1]);
for(boost::tokenizer<>::const_iterator iter = dimtokens.begin();
iter != dimtokens.end();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment