summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/mktemp.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-05-27 18:20:45 +0000
committermillert <millert@openbsd.org>2002-05-27 18:20:45 +0000
commit7c7d150b4db8e4857b73a676a81845c89d749525 (patch)
tree8aa37f010d8d9242b29b9c710a36501674f9639c /lib/libc/stdio/mktemp.c
parentif_attach() gets called before domaininit(). scan all interfaces for if_afdata (diff)
downloadwireguard-openbsd-7c7d150b4db8e4857b73a676a81845c89d749525.tar.xz
wireguard-openbsd-7c7d150b4db8e4857b73a676a81845c89d749525.zip
Don't decrement the current character pointer past the beginning of the
buffer passed in. Based on a patch from Mark Andrews. deraadt@ OK
Diffstat (limited to 'lib/libc/stdio/mktemp.c')
-rw-r--r--lib/libc/stdio/mktemp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index 477328d268e..645c86e53ef 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: mktemp.c,v 1.15 2002/02/16 21:27:24 millert Exp $";
+static char rcsid[] = "$OpenBSD: mktemp.c,v 1.16 2002/05/27 18:20:45 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -119,11 +119,11 @@ _gettemp(path, doopen, domkdir, slen)
return (0);
}
pid = getpid();
- while (*trv == 'X' && pid != 0) {
+ while (trv >= path && *trv == 'X' && pid != 0) {
*trv-- = (pid % 10) + '0';
pid /= 10;
}
- while (*trv == 'X') {
+ while (trv >= path && *trv == 'X') {
char c;
pid = (arc4random() & 0xffff) % (26+26);