From: Zbigniew Jędrzejewski-Szmek Date: Tue, 5 Nov 2019 17:15:46 +0000 (+0100) Subject: core/dbus-cgroup: use %.*s instead of strndupa() X-Git-Tag: v244-rc1~27^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e617e2ccd790fda92efadcb917ba90de9f832022;p=thirdparty%2Fsystemd.git core/dbus-cgroup: use %.*s instead of strndupa() --- diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 8e8e3dca4b3..591c5dd7f52 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -692,16 +692,14 @@ static int bus_cgroup_set_boolean( "Value specified in %s is out of range", name); \ \ if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \ - const char *e; \ - \ *p = v; \ unit_invalidate_cgroup(u, mask); \ \ - /* Chop off suffix */ \ - assert_se(e = endswith(name, "Scale")); \ - name = strndupa(name, e - name); \ + /* Prepare to chop off suffix */ \ + assert_se(endswith(name, "Scale")); \ \ - unit_write_settingf(u, flags, name, "%s=%" PRIu32 "%%", name, \ + unit_write_settingf(u, flags, name, "%.*s=%" PRIu32 "%%", \ + (int)(strlen(name) - strlen("Scale")), name, \ (uint32_t) (DIV_ROUND_UP((uint64_t) raw * 100U, (uint64_t) UINT32_MAX))); \ } \ \