Commit fe7dd1ca authored by David E. DeMarle's avatar David E. DeMarle

Merge branch 'improve-seek-overflow' into 'master'

replace atoi for seek because that can get overflow easily

See merge request xdmf/xdmf!49
parents e941db22 6c88e16a
......@@ -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