From: Lennart Poettering Date: Wed, 8 Jun 2016 18:04:22 +0000 (+0200) Subject: core: when receiving a memory limit via the bus, refuse 0 X-Git-Tag: v231~152^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd0a7a8e58cf7e9f273bf446bb50bf982a8cf29c;p=platform%2Fupstream%2Fsystemd.git 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. --- diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 8525fa1..5b94b5e 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;