Fix crash in RepositoryUtility::AddObject

fixes #10326
This commit is contained in:
Gunnar Beutner 2015-10-13 09:15:06 +02:00
parent 7c4fa22715
commit 2484016c54
3 changed files with 9 additions and 6 deletions

View File

@ -612,13 +612,13 @@ void Utility::MkDir(const String& path, int flags)
}
}
void Utility::MkDirP(const String& path, int flags)
void Utility::MkDirP(const String& path, int mode)
{
size_t pos = 0;
while (pos != String::NPos) {
pos = path.Find("/", pos + 1);
MkDir(path.SubStr(0, pos), flags);
MkDir(path.SubStr(0, pos), mode);
}
}

View File

@ -81,8 +81,8 @@ public:
static bool Glob(const String& pathSpec, const boost::function<void (const String&)>& callback, int type = GlobFile | GlobDirectory);
static bool GlobRecursive(const String& path, const String& pattern, const boost::function<void (const String&)>& callback, int type = GlobFile | GlobDirectory);
static void MkDir(const String& path, int flags);
static void MkDirP(const String& path, int flags);
static void MkDir(const String& path, int mode);
static void MkDirP(const String& path, int mode);
static bool SetFileOwnership(const String& file, const String& user, const String& group);
static void QueueAsyncCallback(const boost::function<void (void)>& callback, SchedulerPolicy policy = DefaultScheduler);

View File

@ -232,12 +232,13 @@ bool RepositoryUtility::AddObject(const std::vector<String>& object_paths, const
if (check_config) {
try {
Object::Ptr object = utype->Instantiate();
ConfigObject::Ptr object = static_pointer_cast<ConfigObject>(utype->Instantiate());
Deserialize(object, attrs, false, FAConfig);
object->SetName(name);
RepositoryValidationUtils utils;
static_pointer_cast<ConfigObject>(object)->Validate(FAConfig, utils);
} catch (const ScriptError& ex) {
} catch (const ValidationError& ex) {
Log(LogCritical, "config", DiagnosticInformation(ex));
return false;
}
@ -555,6 +556,8 @@ bool RepositoryUtility::GetChangeLog(const boost::function<void (const Dictionar
std::vector<String> changelog;
String path = GetRepositoryChangeLogPath() + "/";
Utility::MkDirP(path, 0700);
Utility::Glob(path + "/*.change",
boost::bind(&RepositoryUtility::CollectChangeLog, _1, boost::ref(changelog)), GlobFile);