Fix a nasty flaw as a result of using the arc4random() pre-seeding of

leading XXX's.  It could wrap an uppercase character through chars
like:  [ \ ] ^ _ `  in between Z and a.  The backslash and back tick
might be particularly nasty in a shell script context.  Also, since
we've been using upper-case generated values for a while now, go with
the flow and use them in the pathname search rotation.
This commit is contained in:
Peter Wemm 1998-04-14 07:25:05 +00:00
parent acf1dcdc9c
commit 4fea76f539

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id: mktemp.c,v 1.8 1998/02/13 02:13:24 imp Exp $";
"$Id: mktemp.c,v 1.9 1998/03/03 14:38:36 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -164,11 +164,13 @@ _gettemp(path, doopen, domkdir)
for (trv = start;;) {
if (!*trv)
return(0);
if (*trv == 'z')
if (*trv == 'Z')
*trv++ = 'a';
else {
if (isdigit(*trv))
*trv = 'a';
else if (*trv == 'z') /* inc from z to A */
*trv = 'A';
else
++*trv;
break;