summaryrefslogtreecommitdiff
path: root/src/core/dbus-cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-06-08 20:04:22 +0200
committerLennart Poettering <lennart@poettering.net>2016-06-14 19:50:38 +0200
commitcd0a7a8e58cf7e9f273bf446bb50bf982a8cf29c (patch)
tree268e16f59aae36c2d5950a440745504cd5df0bc4 /src/core/dbus-cgroup.c
parent328583dbc3621271dbdac4a279865ea7243f8ddf (diff)
core: when receiving a memory limit via the bus, refuse 0
When parsing unit files we already refuse unit memory limits of zero, let's also refuse it when the value is set via the bus.
Diffstat (limited to 'src/core/dbus-cgroup.c')
-rw-r--r--src/core/dbus-cgroup.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 8525fa1bf1..5b94b5e575 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -641,7 +641,7 @@ int bus_cgroup_set_property(
return 1;
- } else if (streq(name, "BlockIOReadBandwidth") || streq(name, "BlockIOWriteBandwidth")) {
+ } else if (STR_IN_SET(name, "BlockIOReadBandwidth", "BlockIOWriteBandwidth")) {
const char *path;
bool read = true;
unsigned n = 0;
@@ -835,6 +835,8 @@ int bus_cgroup_set_property(
r = sd_bus_message_read(message, "t", &v);
if (r < 0)
return r;
+ if (v <= 0)
+ return sd_bus_error_set_errnof(error, EINVAL, "%s= is too small", name);
if (mode != UNIT_CHECK) {
if (streq(name, "MemoryLow"))
@@ -860,6 +862,8 @@ int bus_cgroup_set_property(
r = sd_bus_message_read(message, "t", &limit);
if (r < 0)
return r;
+ if (limit <= 0)
+ return sd_bus_error_set_errnof(error, EINVAL, "%s= is too small", name);
if (mode != UNIT_CHECK) {
c->memory_limit = limit;