]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: check snprintf retval in unpriv_systemd_create_scope
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Fri, 9 Dec 2022 18:34:54 +0000 (19:34 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 16 Dec 2022 16:36:47 +0000 (11:36 -0500)
Reported-by: coverity (CID #1517315)
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
src/lxc/cgroups/cgfsng.c

index 8a3693d29ed69488f065b5ec1f75dfee0721b516..eeb817334fa11fc439a6514937d728e45c300292 100644 (file)
@@ -1268,7 +1268,9 @@ static int unpriv_systemd_create_scope(struct cgroup_ops *ops, struct lxc_conf *
                return syserror("Out of memory");
 
        do {
-               snprintf(full_scope_name, len, "lxc-%s-%d.scope", conf->name, idx);
+               r = strnprintf(full_scope_name, len, "lxc-%s-%d.scope", conf->name, idx);
+               if (r < 0)
+                       return log_error_errno(-1, errno, "Failed to build scope name for \"%s\"", conf->name);
                sd_data.scope_name = full_scope_name;
                if (start_scope(bus, &sd_data, event)) {
                        conf->cgroup_meta.systemd_scope = get_current_unified_cgroup();