fix typo introduced in poll.h
[musl] / src / temp / mkdtemp.c
index cb030ee..76140c7 100644 (file)
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -9,14 +8,19 @@
 #include <sys/stat.h>
 #include "libc.h"
 
+char *__mktemp(char *);
+
 char *mkdtemp(char *template)
 {
-       for (;;) {
-               if (!mktemp(template)) return 0;
+       int retries = 100, t0 = *template;
+       while (retries--) {
+               if (!*__mktemp(template)) return 0;
                if (!mkdir(template, 0700)) return template;
                if (errno != EEXIST) return 0;
                /* this is safe because mktemp verified
                 * that we have a valid template string */
+               template[0] = t0;
                strcpy(template+strlen(template)-6, "XXXXXX");
        }
+       return 0;
 }