summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2010-02-08 17:58:25 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2010-02-08 17:58:25 +0000
commit36b57dbdcb722c47d8af5c5d44b826a085ebc35f (patch)
treee06a53990af685e6233f31070d3d5240429b74fb /lib
parent4c5f4f3a54802746721b1302af392f79896f845e (diff)
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')
-rw-r--r--lib/libc/stdio/mktemp.c9
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;
}