summaryrefslogtreecommitdiff
path: root/usr.bin/mktemp/mktemp.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-25 20:02:03 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-25 20:02:03 +0000
commit07cebfad56982a350f09156ba7ff86d3ed970c30 (patch)
tree3150db7cd024c7c79faab6c3691be9b29a8bceda /usr.bin/mktemp/mktemp.c
parent8fe72f38c9d81398fe239810ea74108c5e7549cb (diff)
Don't assume that asprintf() will leave "tempfile" unmolested when
memory allocation fails. Noted and OK by pval@
Diffstat (limited to 'usr.bin/mktemp/mktemp.c')
-rw-r--r--usr.bin/mktemp/mktemp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c
index 666bbfdb9a2..9e7c12d1f55 100644
--- a/usr.bin/mktemp/mktemp.c
+++ b/usr.bin/mktemp/mktemp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mktemp.c,v 1.9 2003/04/07 19:25:43 millert Exp $ */
+/* $OpenBSD: mktemp.c,v 1.10 2003/04/25 20:02:02 millert Exp $ */
/*
* Copyright (c) 1996, 1997, 2001 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: mktemp.c,v 1.9 2003/04/07 19:25:43 millert Exp $";
+static const char rcsid[] = "$OpenBSD: mktemp.c,v 1.10 2003/04/25 20:02:02 millert Exp $";
#endif /* not lint */
#include <paths.h>
@@ -99,8 +99,8 @@ main(argc, argv)
while (plen != 0 && prefix[plen - 1] == '/')
plen--;
- tempfile = NULL;
- asprintf(&tempfile, "%.*s/%s", plen, prefix, template);
+ if (asprintf(&tempfile, "%.*s/%s", plen, prefix, template) < 0)
+ tempfile = NULL;
} else
tempfile = strdup(template);
if (tempfile == NULL) {