diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mktemp.c | 12 | ||||
-rw-r--r-- | src/sort.c | 3 | ||||
-rw-r--r-- | src/tac.c | 3 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/mktemp.c b/src/mktemp.c index 8a09231f9..d745e6069 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -242,20 +242,24 @@ main (int argc, char **argv) quote (template)); } - dest_name = file_name_concat (dest_dir, template, NULL); + template = file_name_concat (dest_dir, template, NULL); } else { - dest_name = xstrdup (template); + template = xstrdup (template); } + /* Make a copy to be used in case of diagnostic, since failing + mkstemp may leave the buffer in an undefined state. */ + dest_name = xstrdup (template); + if (create_directory) { int err = mkdtemp_len (dest_name, x_count, dry_run); if (err != 0) { error (0, errno, _("failed to create directory via template %s"), - quote (dest_name)); + quote (template)); status = EXIT_FAILURE; } } @@ -265,7 +269,7 @@ main (int argc, char **argv) if (fd < 0 || (!dry_run && close (fd) != 0)) { error (0, errno, _("failed to create file via template %s"), - quote (dest_name)); + quote (template)); status = EXIT_FAILURE; } } diff --git a/src/sort.c b/src/sort.c index b932a51b3..92f400a96 100644 --- a/src/sort.c +++ b/src/sort.c @@ -741,7 +741,8 @@ create_temp_file (int *pfd) errno = saved_errno; if (fd < 0) - die (_("cannot create temporary file"), file); + error (SORT_FAILURE, errno, _("cannot create temporary file in %s"), + quote (temp_dir)); *pfd = fd; return node; @@ -454,7 +454,8 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) fd = mkstemp (template); if (fd < 0) { - error (0, errno, _("cannot create temporary file %s"), quote (tempfile)); + error (0, errno, _("cannot create temporary file in %s"), + quote (tempdir)); return false; } |