Module Name: src Committed By: snj Date: Thu Apr 16 06:33:59 UTC 2015
Modified Files: src/lib/libc/stdio [netbsd-5]: gettemp.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1955): lib/libc/stdio/gettemp.c: revision 1.16 via patch 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.14 -r1.14.2.1 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.14 src/lib/libc/stdio/gettemp.c:1.14.2.1 --- src/lib/libc/stdio/gettemp.c:1.14 Mon Oct 20 10:28:38 2008 +++ src/lib/libc/stdio/gettemp.c Thu Apr 16 06:33:59 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: gettemp.c,v 1.14 2008/10/20 10:28:38 apb Exp $ */ +/* $NetBSD: gettemp.c,v 1.14.2.1 2015/04/16 06:33:59 snj 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.14 2008/10/20 10:28:38 apb Exp $"); +__RCSID("$NetBSD: gettemp.c,v 1.14.2.1 2015/04/16 06:33:59 snj Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -122,14 +122,16 @@ GETTEMP(path, doopen, domkdir) 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; } }