diff options
author | Sascha Grunert <sgrunert@suse.com> | 2019-06-20 13:38:16 +0200 |
---|---|---|
committer | Sascha Grunert <sgrunert@suse.com> | 2019-06-20 14:52:32 +0200 |
commit | fa1b0a2d891d393d6762654d8385ef0347e1adfa (patch) | |
tree | 7979567721e07bf736c474469df82f08c4bdcf2d /pkg/rootless | |
parent | b4f9bc868e2f5b3ffc5b7487be9d7b717dd6ae5b (diff) | |
download | podman-fa1b0a2d891d393d6762654d8385ef0347e1adfa.tar.gz podman-fa1b0a2d891d393d6762654d8385ef0347e1adfa.tar.bz2 podman-fa1b0a2d891d393d6762654d8385ef0347e1adfa.zip |
Handle possible asprintf failure in rootless_linux.c
If `asprintf` fails we early exit now.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Diffstat (limited to 'pkg/rootless')
-rw-r--r-- | pkg/rootless/rootless_linux.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index eb62d55e9..5ab368691 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -416,9 +416,16 @@ create_pause_process (const char *pause_pid_file_path, char **argv) sprintf (pid_str, "%d", pid); - asprintf (&tmp_file_path, "%s.XXXXXX", pause_pid_file_path); + if (asprintf (&tmp_file_path, "%s.XXXXXX", pause_pid_file_path) < 0) + { + fprintf (stderr, "unable to print to string\n"); + kill (pid, SIGKILL); + _exit (EXIT_FAILURE); + } + if (tmp_file_path == NULL) { + fprintf (stderr, "temporary file path is NULL\n"); kill (pid, SIGKILL); _exit (EXIT_FAILURE); } @@ -426,6 +433,7 @@ create_pause_process (const char *pause_pid_file_path, char **argv) fd = mkstemp (tmp_file_path); if (fd < 0) { + fprintf (stderr, "error creating temporary file: %s\n", strerror (errno)); kill (pid, SIGKILL); _exit (EXIT_FAILURE); } @@ -433,6 +441,7 @@ create_pause_process (const char *pause_pid_file_path, char **argv) r = TEMP_FAILURE_RETRY (write (fd, pid_str, strlen (pid_str))); if (r < 0) { + fprintf (stderr, "cannot write to file descriptor: %s\n", strerror (errno)); kill (pid, SIGKILL); _exit (EXIT_FAILURE); } |