[hackers] [scc] [driver] fix temporary object generation for old POSIX || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sun, 4 Dec 2016 12:54:35 +0100 (CET)

commit 700201165e35131fd7c6e64e8e97f591a9724500
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sun Dec 4 10:36:21 2016 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sun Dec 4 12:30:55 2016 +0100

    [driver] fix temporary object generation for old POSIX
    
    Pre-susv4 mkstemp don't impose a filename format and don't provide
    EINVAL error on which we were counting.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 74f5299..7f3e64e 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -163,10 +163,12 @@ outfname(char *path, char *type)
         n = snprintf(new, newsz, "%.*s%c%s", (int)pathln, path, sep, type);
         if (n < 0 || n >= newsz)
                 die("scc: wrong output filename");
- if ((tmpfd = mkstemp(new)) < 0 && errno != EINVAL)
- die("scc: could not create output file '%s': %s",
- new, strerror(errno));
- close(tmpfd);
+ if (sep == '/') {
+ if ((tmpfd = mkstemp(new)) < 0)
+ die("scc: could not create output file '%s': %s",
+ new, strerror(errno));
+ close(tmpfd);
+ }
 
         return new;
 }
Received on Sun Dec 04 2016 - 12:54:35 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 04 2016 - 13:00:21 CET