utils: check snprintf return value

Fixes: Coverity 1465853 Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 8ddf34f7
...@@ -1097,7 +1097,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co ...@@ -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)); target_fd = openat2(beneath_fd, dst, &how, sizeof(how));
if (target_fd < 0) if (target_fd < 0)
return -errno; 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)) if (!is_empty_string(src_buf))
ret = mount(src_buf, tgt_buf, fstype, flags, data); ret = mount(src_buf, tgt_buf, fstype, flags, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment