mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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:
parent
04ba40bc02
commit
5f02be00bc
1 changed files with 2 additions and 2 deletions
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue