From 81a9fe1c8eae8460ad5dfbe48134556ebbc5b24b Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Sun, 9 Mar 2014 09:42:49 -0400 Subject: [PATCH] inet_pton() can return 0 or -1 as errors. We wern't likely to see -1 in practice (it's documented to be only emitted when inet_pton is provided an unrecognized address family), but best to be completely correct. --- ifchd/linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ifchd/linux.c b/ifchd/linux.c index 7359cb3..d2fb72a 100644 --- a/ifchd/linux.c +++ b/ifchd/linux.c @@ -163,7 +163,7 @@ void perform_ip(struct ifchd_client *cl, const char *str, size_t len) return; if (!is_permitted(cl->ifnam)) return; - if (!inet_pton(AF_INET, str, &ipaddr)) + if (inet_pton(AF_INET, str, &ipaddr) <= 0) return; if (set_if_flag(cl, (IFF_UP | IFF_RUNNING))) return; @@ -200,7 +200,7 @@ void perform_subnet(struct ifchd_client *cl, const char *str, size_t len) return; if (!is_permitted(cl->ifnam)) return; - if (!inet_pton(AF_INET, str, &subnet)) + if (inet_pton(AF_INET, str, &subnet) <= 0) return; strnkcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ); @@ -238,7 +238,7 @@ void perform_router(struct ifchd_client *cl, const char *str, size_t len) return; if (!is_permitted(cl->ifnam)) return; - if (!inet_pton(AF_INET, str, &router)) + if (inet_pton(AF_INET, str, &router) <= 0) return; memset(&rt, 0, sizeof(struct rtentry)); @@ -315,7 +315,7 @@ void perform_broadcast(struct ifchd_client *cl, const char *str, size_t len) return; if (!is_permitted(cl->ifnam)) return; - if (!inet_pton(AF_INET, str, &broadcast)) + if (inet_pton(AF_INET, str, &broadcast) <= 0) return; strnkcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ);