Unverified Commit 49ce8186 by Stéphane Graber Committed by GitHub

Merge pull request #2936 from brauner/2019-04-14/issue_2935

cgroups: fix potential nullderef
parents 30a9d137 b53a0853
...@@ -522,13 +522,17 @@ static bool copy_parent_file(char *path, char *file) ...@@ -522,13 +522,17 @@ static bool copy_parent_file(char *path, char *file)
*lastslash = '\0'; *lastslash = '\0';
parent_path = must_make_path(path, file, NULL); parent_path = must_make_path(path, file, NULL);
len = lxc_read_from_file(parent_path, NULL, 0); len = lxc_read_from_file(parent_path, NULL, 0);
if (len <= 0) if (len <= 0) {
goto on_error; SYSERROR("Failed to determine buffer size");
return false;
}
value = must_realloc(NULL, len + 1); value = must_realloc(NULL, len + 1);
ret = lxc_read_from_file(parent_path, value, len); ret = lxc_read_from_file(parent_path, value, len);
if (ret != len) if (ret != len) {
goto on_error; SYSERROR("Failed to read from parent file \"%s\"", parent_path);
return false;
}
*lastslash = oldv; *lastslash = oldv;
child_path = must_make_path(path, file, NULL); child_path = must_make_path(path, file, NULL);
...@@ -536,10 +540,6 @@ static bool copy_parent_file(char *path, char *file) ...@@ -536,10 +540,6 @@ static bool copy_parent_file(char *path, char *file)
if (ret < 0) if (ret < 0)
SYSERROR("Failed to write \"%s\" to file \"%s\"", value, child_path); SYSERROR("Failed to write \"%s\" to file \"%s\"", value, child_path);
return ret >= 0; return ret >= 0;
on_error:
SYSERROR("Failed to read file \"%s\"", child_path);
return false;
} }
/* Initialize the cpuset hierarchy in first directory of @gname and set /* Initialize the cpuset hierarchy in first directory of @gname and set
......
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