diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-02-17 22:53:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-02-17 22:53:44 +0000 |
commit | 6fcf2a941bd040d45ce22df49a1cd7c08eb3ec71 (patch) | |
tree | 83d32c8943ffdbe6b54e28be94c1415b7f566967 /lib | |
parent | a867855445ba4c176695a9ea07d1916cb1c74157 (diff) |
when the template is entirely XXX characters, would crash
from Vadim Zhukov <persgray@gmail
ok millert
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdio/mktemp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index b88ef741fd7..dcc50b7f0f9 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mktemp.c,v 1.24 2008/09/15 20:28:44 chl Exp $ */ +/* $OpenBSD: mktemp.c,v 1.25 2009/02/17 22:53:43 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 * The Regents of the University of California. All rights reserved. @@ -100,9 +100,11 @@ _gettemp(char *path, int *doopen, int domkdir, int slen) } ep = path + len - slen; - for (start = ep; *--start == 'X';) - ; - start++; + for (start = ep - 1; start != path; start--) + if (*start != 'X') { + start++; + break; + } for (;;) { for (cp = start; cp != ep; cp++) { |