Skip to content

Commit

Permalink
utils: check snprintf return value
Browse files Browse the repository at this point in the history
Fixes: Coverity 1465853
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Oct 28, 2020
1 parent 8ddf34f commit 0dde733
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lxc/utils.c
Expand Up @@ -1097,7 +1097,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co
target_fd = openat2(beneath_fd, dst, &how, sizeof(how));
if (target_fd < 0)
return -errno;
snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd);
ret = snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd);
if (ret < 0 || ret >= sizeof(tgt_buf))
return -EIO;

if (!is_empty_string(src_buf))
ret = mount(src_buf, tgt_buf, fstype, flags, data);
Expand Down

0 comments on commit 0dde733

Please sign in to comment.