fix tempnam name generation, and a small bug in tmpnam on retry limit
[musl] / src / stdio / tmpnam.c
index 6099b74..010cf03 100644 (file)
@@ -26,5 +26,5 @@ char *tmpnam(char *s)
                n = ts.tv_nsec ^ (unsigned)&s ^ (unsigned)s;
                snprintf(s, L_tmpnam, "/tmp/t%x-%x", a_fetch_add(&index, 1), n);
        } while (!__syscall(SYS_access, s, F_OK) && try++<MAXTRIES);
-       return try==MAXTRIES ? 0 : s;
+       return try>=MAXTRIES ? 0 : s;
 }