From: Joel Rosdahl Date: Sun, 6 Dec 2015 19:30:39 +0000 (+0100) Subject: Don't assume that mkstemp leaves template unmodified on error X-Git-Tag: v3.2.5~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07a529dfeb452cf6bb77b5a317539eeda54b40fd;p=thirdparty%2Fccache.git Don't assume that mkstemp leaves template unmodified on error This fixes a problem seen on QNX. --- diff --git a/util.c b/util.c index 739e3aff1..a2ba7151d 100644 --- a/util.c +++ b/util.c @@ -1180,15 +1180,16 @@ create_tmp_fd(char **fname) char *template = format("%s.%s", *fname, tmp_string()); int fd = mkstemp(template); if (fd == -1 && errno == ENOENT) { - if (create_parent_dirs(template) != 0) { + if (create_parent_dirs(*fname) != 0) { fatal("Failed to create directory %s: %s", - dirname(template), strerror(errno)); + dirname(*fname), strerror(errno)); } reformat(&template, "%s.%s", *fname, tmp_string()); fd = mkstemp(template); } if (fd == -1) { - fatal("Failed to create file %s: %s", template, strerror(errno)); + fatal("Failed to create temporary file for %s: %s", + *fname, strerror(errno)); } #ifndef _WIN32