summaryrefslogtreecommitdiff
path: root/sbin/ipsecctl/parse.y
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-06-03 02:24:37 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-06-03 02:24:37 +0000
commit53f83ea972c751a287eed99558f9349e7238bc9f (patch)
tree98e3342250c23ad4626e591e9c43381815c024c7 /sbin/ipsecctl/parse.y
parentcf757a3268b6ecc9b77a4d2c3e3d4932433013a3 (diff)
Do not assume that asprintf() clears the pointer on failure, which
is non-portable. Also add missing asprintf() return value checks. OK deraadt@ guenther@ doug@
Diffstat (limited to 'sbin/ipsecctl/parse.y')
-rw-r--r--sbin/ipsecctl/parse.y13
1 files changed, 7 insertions, 6 deletions
diff --git a/sbin/ipsecctl/parse.y b/sbin/ipsecctl/parse.y
index 86d02492640..cab02d25c40 100644
--- a/sbin/ipsecctl/parse.y
+++ b/sbin/ipsecctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.161 2014/11/20 05:51:20 jsg Exp $ */
+/* $OpenBSD: parse.y,v 1.162 2015/06/03 02:24:36 millert Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1613,11 +1613,12 @@ host_v6(const char *s, int prefixlen)
if (prefixlen != 128) {
ipa->netaddress = 1;
- asprintf(&ipa->name, "%s/%d", hbuf, prefixlen);
- } else
- ipa->name = strdup(hbuf);
- if (ipa->name == NULL)
- err(1, "host_v6: strdup");
+ if (asprintf(&ipa->name, "%s/%d", hbuf, prefixlen) == -1)
+ err(1, "host_v6: asprintf");
+ } else {
+ if ((ipa->name = strdup(hbuf)) == NULL)
+ err(1, "host_v6: strdup");
+ }
freeaddrinfo(res);