While comparing this with OpenBSD (ie: trying to figure out what mkstemps()

is good for... :-)), I discovered that part of the change when mkstemps()
was brought in was missed - it was missing the termination case to make
sure it doesn't walk into the suffix.  This isn't the same code OpenBSD
has, I think this is a little better as we terminate the loop in a better
spot.
This commit is contained in:
Peter Wemm 1999-12-11 14:48:24 +00:00
parent 04ba40bc02
commit 5f02be00bc

View file

@ -111,7 +111,6 @@ _gettemp(path, doopen, domkdir, slen)
return(0);
}
pid = getpid();
for (trv = path; *trv; ++trv)
;
trv -= slen;
@ -121,6 +120,7 @@ _gettemp(path, doopen, domkdir, slen)
errno = EINVAL;
return (0);
}
pid = getpid();
while (*trv == 'X' && pid != 0) {
*trv-- = (pid % 10) + '0';
pid /= 10;
@ -177,7 +177,7 @@ _gettemp(path, doopen, domkdir, slen)
/* tricky little algorithm for backward compatibility */
for (trv = start;;) {
if (!*trv)
if (*trv == '\0' || trv == suffp)
return(0);
if (*trv == 'Z')
*trv++ = 'a';