$OpenBSD: patch-ae,v 1.2 2000/06/07 00:52:09 espie Exp $ --- sam/unix.c.orig Wed Jun 7 02:38:23 2000 +++ sam/unix.c Wed Jun 7 02:38:26 2000 @@ -147,18 +147,18 @@ notifyf(void *a, char *b) /* never calle 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