mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
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);
|
Utility::MkDirP(path, 0700);
|
||||||
WriteStageConfig(moduleName, stageName);
|
WriteStageConfig(moduleName, stageName);
|
||||||
|
|
||||||
|
bool foundDotDot = false;
|
||||||
ObjectLock olock(files);
|
ObjectLock olock(files);
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, files) {
|
BOOST_FOREACH(const Dictionary::Pair& kv, files) {
|
||||||
if (ContainsDotDot(kv.first))
|
if (ContainsDotDot(kv.first)) {
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Path must not contain '..'."));
|
foundDotDot = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
String filePath = path + "/" + kv.first;
|
String filePath = path + "/" + kv.first;
|
||||||
|
|
||||||
@ -101,6 +104,11 @@ String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictiona
|
|||||||
fp.close();
|
fp.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundDotDot) {
|
||||||
|
Utility::RemoveDirRecursive(path);
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Path must not contain '..'."));
|
||||||
|
}
|
||||||
|
|
||||||
return stageName;
|
return stageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user