diff options
author | 2003-04-25 20:02:02 +0000 | |
---|---|---|
committer | 2003-04-25 20:02:02 +0000 | |
commit | bdf17bbed85e8a9dff959c09ef30c0605146282b (patch) | |
tree | 209a249b899a630b510c6e820adca2b0b955c12f | |
parent | kill a workaround now that inet_net_pton acts reasonably (diff) | |
download | wireguard-openbsd-bdf17bbed85e8a9dff959c09ef30c0605146282b.tar.xz wireguard-openbsd-bdf17bbed85e8a9dff959c09ef30c0605146282b.zip |
Don't assume that asprintf() will leave "tempfile" unmolested when
memory allocation fails. Noted and OK by pval@
-rw-r--r-- | usr.bin/mktemp/mktemp.c | 8 |
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) { |