123456789101112131415161718192021222324252627282930313233 |
- $OpenBSD: patch-sam_unix_c,v 1.2 2016/03/17 21:07:32 naddy Exp $
- --- sam/unix.c.orig Thu Mar 17 21:21:48 2016
- +++ sam/unix.c Thu Mar 17 21:21:48 2016
- @@ -147,18 +147,18 @@ notifyf(void *a, char *b) /* never called */
- int
- newtmp(int i)
- {
- - char *s;
- - FILE *f;
- - extern char *tempnam(const char*, const char*);
- + char file[40];
- + int fd;
- + extern int mkstemp(char *);
-
- - s = tempnam(TMPDIR, "sam.");
- - if (!s)
- + snprintf(file, 40, "%s/sam.XXXXXXXXXX", TMPDIR);
- + fd = mkstemp(file);
- + if(fd < 0){
- + unlink(file);
- return -1;
- - f = fopen(s, "w+");
- - if (!f)
- - return -1;
- - unlink(s);
- - return fileno(f);
- + }
- + unlink(file);
- + return fd;
- }
-
- void
|