mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-28 06:35:34 +07:00
Add sanity checks to paths in cgroup-util.c
This is part of upstream commit 9444b1f20e311f073864d81e913bd4f32fe95cfd Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This commit is contained in:
parent
68db594ba6
commit
c9096d0490
@ -169,19 +169,19 @@ static const char *normalize_controller(const char *controller) {
|
||||
static int join_path(const char *controller, const char *path, const char *suffix, char **fs) {
|
||||
char *t = NULL;
|
||||
|
||||
if (controller) {
|
||||
if (path && suffix)
|
||||
if (!isempty(controller)) {
|
||||
if (!isempty(path) && !isempty(suffix))
|
||||
t = strjoin("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL);
|
||||
else if (path)
|
||||
else if (!isempty(path))
|
||||
t = strjoin("/sys/fs/cgroup/", controller, "/", path, NULL);
|
||||
else if (suffix)
|
||||
else if (!isempty(suffix))
|
||||
t = strjoin("/sys/fs/cgroup/", controller, "/", suffix, NULL);
|
||||
else
|
||||
t = strappend("/sys/fs/cgroup/", controller);
|
||||
} else {
|
||||
if (path && suffix)
|
||||
if (!isempty(path) && !isempty(suffix))
|
||||
t = strjoin(path, "/", suffix, NULL);
|
||||
else if (path)
|
||||
else if (!isempty(path))
|
||||
t = strdup(path);
|
||||
else
|
||||
return -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user