mirror of https://github.com/Icinga/icinga2.git
Fix a problem where invalid stage config could lead into broken stages
refs #9103 refs #9083
This commit is contained in:
parent
fca7a33aac
commit
fa3d380dff
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue