summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/tempnam.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/tempnam.c')
-rw-r--r--lib/libc/stdio/tempnam.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/stdio/tempnam.c b/lib/libc/stdio/tempnam.c
index e3f2ab6476c..56d667dadd4 100644
--- a/lib/libc/stdio/tempnam.c
+++ b/lib/libc/stdio/tempnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tempnam.c,v 1.17 2013/09/30 12:02:35 millert Exp $ */
+/* $OpenBSD: tempnam.c,v 1.18 2015/03/23 22:15:11 jsg Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -58,7 +58,7 @@ tempnam(const char *dir, const char *pfx)
f[strlen(f) - 1] == '/' ? "" : "/", pfx);
if (len < 0 || len >= PATH_MAX) {
errno = ENAMETOOLONG;
- return(NULL);
+ goto fail;
}
if ((f = _mktemp(name)))
return(f);
@@ -70,7 +70,7 @@ tempnam(const char *dir, const char *pfx)
f[strlen(f) - 1] == '/' ? "" : "/", pfx);
if (len < 0 || len >= PATH_MAX) {
errno = ENAMETOOLONG;
- return(NULL);
+ goto fail;
}
if ((f = _mktemp(name)))
return(f);
@@ -80,7 +80,7 @@ tempnam(const char *dir, const char *pfx)
len = snprintf(name, PATH_MAX, "%s%sXXXXXXXXX", f, pfx);
if (len < 0 || len >= PATH_MAX) {
errno = ENAMETOOLONG;
- return(NULL);
+ goto fail;
}
if ((f = _mktemp(name)))
return(f);
@@ -89,11 +89,12 @@ tempnam(const char *dir, const char *pfx)
len = snprintf(name, PATH_MAX, "%s%sXXXXXXXXX", f, pfx);
if (len < 0 || len >= PATH_MAX) {
errno = ENAMETOOLONG;
- return(NULL);
+ goto fail;
}
if ((f = _mktemp(name)))
return(f);
+fail:
sverrno = errno;
free(name);
errno = sverrno;