mktemp.c (98937) | mktemp.c (106121) |
---|---|
1/* THIS FILE HAS BEEN MODIFIED FROM THE ORIGINAL OPENBSD SOURCE */ 2/* Changes: Removed mktemp */ 3 4/* 5 * Copyright (c) 1987, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#include "includes.h" 38 39#ifndef HAVE_MKDTEMP 40 41#if defined(LIBC_SCCS) && !defined(lint) | 1/* THIS FILE HAS BEEN MODIFIED FROM THE ORIGINAL OPENBSD SOURCE */ 2/* Changes: Removed mktemp */ 3 4/* 5 * Copyright (c) 1987, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#include "includes.h" 38 39#ifndef HAVE_MKDTEMP 40 41#if defined(LIBC_SCCS) && !defined(lint) |
42static char rcsid[] = "$OpenBSD: mktemp.c,v 1.14 2002/01/02 20:18:32 deraadt Exp $"; | 42static char rcsid[] = "$OpenBSD: mktemp.c,v 1.16 2002/05/27 18:20:45 millert Exp $"; |
43#endif /* LIBC_SCCS and not lint */ 44 45#ifdef HAVE_CYGWIN 46#define open binary_open 47extern int binary_open(); 48#endif 49 50static int _gettemp(char *, int *, int, int); --- 46 unchanged lines hidden (view full) --- 97 trv -= slen; 98 suffp = trv; 99 --trv; 100 if (trv < path) { 101 errno = EINVAL; 102 return (0); 103 } 104 pid = getpid(); | 43#endif /* LIBC_SCCS and not lint */ 44 45#ifdef HAVE_CYGWIN 46#define open binary_open 47extern int binary_open(); 48#endif 49 50static int _gettemp(char *, int *, int, int); --- 46 unchanged lines hidden (view full) --- 97 trv -= slen; 98 suffp = trv; 99 --trv; 100 if (trv < path) { 101 errno = EINVAL; 102 return (0); 103 } 104 pid = getpid(); |
105 while (*trv == 'X' && pid != 0) { | 105 while (trv >= path && *trv == 'X' && pid != 0) { |
106 *trv-- = (pid % 10) + '0'; 107 pid /= 10; 108 } | 106 *trv-- = (pid % 10) + '0'; 107 pid /= 10; 108 } |
109 while (*trv == 'X') { | 109 while (trv >= path && *trv == 'X') { |
110 char c; 111 112 pid = (arc4random() & 0xffff) % (26+26); 113 if (pid < 26) 114 c = pid + 'A'; 115 else 116 c = (pid - 26) + 'a'; 117 *trv-- = c; --- 67 unchanged lines hidden --- | 110 char c; 111 112 pid = (arc4random() & 0xffff) % (26+26); 113 if (pid < 26) 114 c = pid + 'A'; 115 else 116 c = (pid - 26) + 'a'; 117 *trv-- = c; --- 67 unchanged lines hidden --- |