summaryrefslogtreecommitdiff
path: root/addrmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'addrmatch.c')
-rw-r--r--addrmatch.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/addrmatch.c b/addrmatch.c
index 8658e105..5a402d06 100644
--- a/addrmatch.c
+++ b/addrmatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: addrmatch.c,v 1.13 2016/09/21 16:55:42 djm Exp $ */
+/* $OpenBSD: addrmatch.c,v 1.14 2018/07/31 03:07:24 djm Exp $ */
/*
* Copyright (c) 2004-2008 Damien Miller <djm@mindrot.org>
@@ -205,25 +205,24 @@ addr_cmp(const struct xaddr *a, const struct xaddr *b)
static int
addr_pton(const char *p, struct xaddr *n)
{
- struct addrinfo hints, *ai;
+ struct addrinfo hints, *ai = NULL;
+ int ret = -1;
memset(&hints, '\0', sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
if (p == NULL || getaddrinfo(p, NULL, &hints, &ai) != 0)
- return -1;
-
+ goto out;
if (ai == NULL || ai->ai_addr == NULL)
- return -1;
-
- if (n != NULL &&
- addr_sa_to_xaddr(ai->ai_addr, ai->ai_addrlen, n) == -1) {
+ goto out;
+ if (n != NULL && addr_sa_to_xaddr(ai->ai_addr, ai->ai_addrlen, n) == -1)
+ goto out;
+ /* success */
+ ret = 0;
+ out:
+ if (ai != NULL)
freeaddrinfo(ai);
- return -1;
- }
-
- freeaddrinfo(ai);
- return 0;
+ return ret;
}
/*