Skip to content

Commit

Permalink
rexec: convert to strnprintf()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent c937bea commit c829cc0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lxc/rexec.c
Expand Up @@ -98,9 +98,9 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
if (memfd < 0) {
char template[PATH_MAX];

ret = snprintf(template, sizeof(template),
P_tmpdir "/.%s_XXXXXX", memfd_name);
if (ret < 0 || (size_t)ret >= sizeof(template))
ret = strnprintf(template, sizeof(template),
P_tmpdir "/.%s_XXXXXX", memfd_name);
if (ret < 0)
return;

tmpfd = lxc_make_tmpfile(template, true);
Expand Down Expand Up @@ -151,8 +151,8 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
} else {
char procfd[LXC_PROC_PID_FD_LEN];

ret = snprintf(procfd, sizeof(procfd), "/proc/self/fd/%d", tmpfd);
if (ret < 0 || (size_t)ret >= sizeof(procfd))
ret = strnprintf(procfd, sizeof(procfd), "/proc/self/fd/%d", tmpfd);
if (ret < 0)
return;

execfd = open(procfd, O_PATH | O_CLOEXEC);
Expand Down

0 comments on commit c829cc0

Please sign in to comment.