Skip to content

Commit

Permalink
cgroups: check snprintf retval in unpriv_systemd_create_scope
Browse files Browse the repository at this point in the history
Reported-by: coverity (CID #1517315)
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
  • Loading branch information
mihalicyn authored and stgraber committed Dec 16, 2022
1 parent 0eca8d2 commit 4b434bf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lxc/cgroups/cgfsng.c
Expand Up @@ -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();
Expand Down

0 comments on commit 4b434bf

Please sign in to comment.