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.
This commit is contained in:
parent
6353e1f897
commit
a803d40076
@ -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 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user