chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f4adece
)
core: catch some special cases in cg_slice_to_path()
author
Lennart Poettering
<lennart@poettering.net>
Thu, 30 Apr 2015 10:33:35 +0000
(12:33 +0200)
committer
Sven Eden
<yamakuzure@gmx.net>
Tue, 14 Mar 2017 07:20:15 +0000
(08:20 +0100)
src/shared/cgroup-util.c
patch
|
blob
|
history
diff --git
a/src/shared/cgroup-util.c
b/src/shared/cgroup-util.c
index 2654efa1ceb279ac24c0beb124df534a6fdee4ac..ce8ebb2ca425bc8b3506c085bf0154b3044ca372 100644
(file)
--- a/
src/shared/cgroup-util.c
+++ b/
src/shared/cgroup-util.c
@@
-1641,6
+1641,16
@@
int cg_slice_to_path(const char *unit, char **ret) {
assert(unit);
assert(ret);
assert(unit);
assert(ret);
+ if (streq(unit, "-.slice")) {
+ char *x;
+
+ x = strdup("");
+ if (!x)
+ return -ENOMEM;
+ *ret = x;
+ return 0;
+ }
+
if (!unit_name_is_valid(unit, TEMPLATE_INVALID))
return -EINVAL;
if (!unit_name_is_valid(unit, TEMPLATE_INVALID))
return -EINVAL;
@@
-1656,8
+1666,10
@@
int cg_slice_to_path(const char *unit, char **ret) {
_cleanup_free_ char *escaped = NULL;
char n[dash - p + sizeof(".slice")];
_cleanup_free_ char *escaped = NULL;
char n[dash - p + sizeof(".slice")];
- strcpy(stpncpy(n, p, dash - p), ".slice");
+ if (isempty(dash + 1))
+ return -EINVAL;
+ strcpy(stpncpy(n, p, dash - p), ".slice");
if (!unit_name_is_valid(n, TEMPLATE_INVALID))
return -EINVAL;
if (!unit_name_is_valid(n, TEMPLATE_INVALID))
return -EINVAL;