]> andersk Git - gssapi-openssh.git/blobdiff - openssh/openbsd-compat/mktemp.c
Import of OpenSSH 3.7.1p2
[gssapi-openssh.git] / openssh / openbsd-compat / mktemp.c
index 9ed1bc80f4eae35d7f50066368d9d3b5a80dff77..2cd74783505eacc12c59afd24901e676af23a3cf 100644 (file)
  * 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.13 1998/06/30 23:03:13 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
@@ -84,7 +80,8 @@ _gettemp(path, doopen, domkdir, slen)
 {
        register char *start, *trv, *suffp;
        struct stat sbuf;
-       int pid, rval;
+       int rval;
+       pid_t pid;
 
        if (doopen && domkdir) {
                errno = EINVAL;
@@ -101,11 +98,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);
@@ -180,4 +177,4 @@ _gettemp(path, doopen, domkdir, slen)
        /*NOTREACHED*/
 }
 
-#endif /* !HAVE_MKDTEMP */
+#endif /* !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) */
This page took 0.032851 seconds and 4 git commands to generate.