Fix a problem where invalid stage config could lead into broken stages

refs #9103
refs #9083
This commit is contained in:
Michael Friedrich 2015-07-24 16:05:13 +02:00
parent fca7a33aac
commit fa3d380dff
1 changed files with 10 additions and 2 deletions

View File

@ -84,10 +84,13 @@ String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictiona
Utility::MkDirP(path, 0700);
WriteStageConfig(moduleName, stageName);
bool foundDotDot = false;
ObjectLock olock(files);
BOOST_FOREACH(const Dictionary::Pair& kv, files) {
if (ContainsDotDot(kv.first))
BOOST_THROW_EXCEPTION(std::invalid_argument("Path must not contain '..'."));
if (ContainsDotDot(kv.first)) {
foundDotDot = true;
break;
}
String filePath = path + "/" + kv.first;
@ -101,6 +104,11 @@ String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictiona
fp.close();
}
if (foundDotDot) {
Utility::RemoveDirRecursive(path);
BOOST_THROW_EXCEPTION(std::invalid_argument("Path must not contain '..'."));
}
return stageName;
}