Module Name: src Committed By: christos Date: Mon Apr 22 20:57:36 UTC 2013
Modified Files: src/lib/libc/stdio: gettemp.c Log Message: PR/47757: Eric Radman: mktemp(3) mangles the pathname if not given an absolute path 1. on error, gettemp() did not restore the path string 2. when emulating mktemp() it is not an error for the pattern not to represent a real directory structure XXX[1]: pullup-5, pullup-6 XXX[2]: the default pattern is the simplistic <pid><X> for mktemp. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/stdio/gettemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdio/gettemp.c diff -u src/lib/libc/stdio/gettemp.c:1.15 src/lib/libc/stdio/gettemp.c:1.16 --- src/lib/libc/stdio/gettemp.c:1.15 Thu Mar 15 14:22:30 2012 +++ src/lib/libc/stdio/gettemp.c Mon Apr 22 16:57:36 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: gettemp.c,v 1.15 2012/03/15 18:22:30 christos Exp $ */ +/* $NetBSD: gettemp.c,v 1.16 2013/04/22 20:57:36 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: gettemp.c,v 1.15 2012/03/15 18:22:30 christos Exp $"); +__RCSID("$NetBSD: gettemp.c,v 1.16 2013/04/22 20:57:36 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -119,14 +119,16 @@ GETTEMP(char *path, int *doopen, int dom if (trv <= path) break; if (*trv == '/') { + int e; *trv = '\0'; - if (stat(path, &sbuf)) - return 0; + e = stat(path, &sbuf); + *trv = '/'; + if (e == -1) + return doopen == NULL && !domkdir; if (!S_ISDIR(sbuf.st_mode)) { errno = ENOTDIR; - return 0; + return doopen == NULL && !domkdir; } - *trv = '/'; break; } }