diff options
author | peter <peter@FreeBSD.org> | 1999-12-11 14:48:24 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-12-11 14:48:24 +0000 |
commit | afa6f15fc776bfa99c2d1c399bf36073c33a3c81 (patch) | |
tree | b6e62e9cc1dd1d234ac7b35488953e86221ac41c /lib/libc | |
parent | f15cf10ca653a3922b8eba30eb4ea79c25d7392d (diff) | |
download | FreeBSD-src-afa6f15fc776bfa99c2d1c399bf36073c33a3c81.zip FreeBSD-src-afa6f15fc776bfa99c2d1c399bf36073c33a3c81.tar.gz |
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.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/mktemp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index af547c6..cd24449 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -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'; |