]> andersk Git - openssh.git/blobdiff - openbsd-compat/mktemp.c
- (tim) [configure.ac] Some platforms need sys/types.h for arpa/nameser.h.
[openssh.git] / openbsd-compat / mktemp.c
index d69dc5c24a5bb75d5c5ab244d714fa1e5a57745b..969f6958064102528236fbe6c3c2bdbc3506a2ae 100644 (file)
@@ -1,3 +1,5 @@
+/* OPENBSD ORIGINAL: lib/libc/stdio/mktemp.c */
+
 /* THIS FILE HAS BEEN MODIFIED FROM THE ORIGINAL OPENBSD SOURCE */
 /* Changes: Removed mktemp */
 
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
 
 #include "includes.h"
 
-#ifndef HAVE_MKDTEMP
+#if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP)
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: mktemp.c,v 1.14 2002/01/02 20:18:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $";
 #endif /* LIBC_SCCS and not lint */
 
-#ifdef HAVE_CYGWIN
-#define open binary_open
-extern int binary_open();
-#endif
-
 static int _gettemp(char *, int *, int, int);
 
 int
@@ -102,11 +95,11 @@ _gettemp(path, doopen, domkdir, slen)
                return (0);
        }
        pid = getpid();
-       while (*trv == 'X' && pid != 0) {
+       while (trv >= path && *trv == 'X' && pid != 0) {
                *trv-- = (pid % 10) + '0';
                pid /= 10;
        }
-       while (*trv == 'X') {
+       while (trv >= path && *trv == 'X') {
                char c;
 
                pid = (arc4random() & 0xffff) % (26+26);
@@ -181,4 +174,4 @@ _gettemp(path, doopen, domkdir, slen)
        /*NOTREACHED*/
 }
 
-#endif /* !HAVE_MKDTEMP */
+#endif /* !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) */
This page took 0.035596 seconds and 4 git commands to generate.