diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-02-11 16:48:37 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-02-11 16:48:37 +0000 |
commit | 26f8fecfda4bfdf38dd05d6104374db156dc76cf (patch) | |
tree | 9482e59e1660308677d21f0ba35b1d42cf7ba3ce | |
parent | 2e57307e4dbd48d417a9e756276bae6abcdc202d (diff) |
The previous commit didn't use the first X in the template if the
entire template was Xs. Test suite written now to keep this from
happening again. Problem caught by Vadim Zhukov again.
ok millert@
-rw-r--r-- | lib/libc/stdio/mktemp.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index b0d18fa7cbc..abf5fa5b28c 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mktemp.c,v 1.28 2010/02/08 17:58:24 guenther Exp $ */ +/* $OpenBSD: mktemp.c,v 1.29 2010/02/11 16:48:36 guenther Exp $ */ /* * Copyright (c) 1996-1998, 2008 Theo de Raadt * Copyright (c) 1997, 2008-2009 Todd C. Miller @@ -52,12 +52,11 @@ 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[-1] == 'X'; start--) { if (tries < INT_MAX / NUM_CHARS) tries *= NUM_CHARS; } tries *= 2; - start++; do { for (cp = start; cp != ep; cp++) { |