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 <[email protected]>
  • Loading branch information
mihalicyn committed Dec 12, 2022
1 parent 93d545e commit 62b94d3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lxc/cgroups/cgfsng.c
Original file line number Diff line number Diff line change
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 62b94d3

Please sign in to comment.