diff options
author | 2010-02-08 17:58:24 +0000 | |
---|---|---|
committer | 2010-02-08 17:58:24 +0000 | |
commit | 5806b33c9c3013583d906ecab896fa5356e238ce (patch) | |
tree | ccc6733616db08a72fe83842ac0569ec566aa6f6 /lib/libc/stdio/mktemp.c | |
parent | Unbreak IPv6 local address lookups. Some idiot aka me optimised a loop and (diff) | |
download | wireguard-openbsd-5806b33c9c3013583d906ecab896fa5356e238ce.tar.xz wireguard-openbsd-5806b33c9c3013583d906ecab896fa5356e238ce.zip |
Don't underrun the buffer when the template is all X's.
Also, remove a duplicate preconditions check.
Based on a suggestion by Vadim Zhukov (persgray <at> gmail.com)
ok millert@
Diffstat (limited to 'lib/libc/stdio/mktemp.c')
-rw-r--r-- | lib/libc/stdio/mktemp.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index 3f35659021f..b0d18fa7cbc 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mktemp.c,v 1.27 2009/03/20 16:05:11 millert Exp $ */ +/* $OpenBSD: mktemp.c,v 1.28 2010/02/08 17:58:24 guenther Exp $ */ /* * Copyright (c) 1996-1998, 2008 Theo de Raadt * Copyright (c) 1997, 2008-2009 Todd C. Miller @@ -44,11 +44,6 @@ mktemp_internal(char *path, int slen, int mode) size_t len; int fd; - if (*path == '\0') { - errno = EINVAL; - return(-1); - } - len = strlen(path); if (len == 0 || slen >= len) { errno = EINVAL; @@ -57,7 +52,7 @@ mktemp_internal(char *path, int slen, int mode) ep = path + len - slen; tries = 1; - for (start = ep; start >= path && *--start == 'X';) { + for (start = ep; start > path && *--start == 'X';) { if (tries < INT_MAX / NUM_CHARS) tries *= NUM_CHARS; } |