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.
This commit is contained in:
Nicholas J. Kain 2014-03-09 09:42:49 -04:00
parent 3ef87c1f26
commit 81a9fe1c8e

View File

@ -163,7 +163,7 @@ void perform_ip(struct ifchd_client *cl, const char *str, size_t len)
return; return;
if (!is_permitted(cl->ifnam)) if (!is_permitted(cl->ifnam))
return; return;
if (!inet_pton(AF_INET, str, &ipaddr)) if (inet_pton(AF_INET, str, &ipaddr) <= 0)
return; return;
if (set_if_flag(cl, (IFF_UP | IFF_RUNNING))) if (set_if_flag(cl, (IFF_UP | IFF_RUNNING)))
return; return;
@ -200,7 +200,7 @@ void perform_subnet(struct ifchd_client *cl, const char *str, size_t len)
return; return;
if (!is_permitted(cl->ifnam)) if (!is_permitted(cl->ifnam))
return; return;
if (!inet_pton(AF_INET, str, &subnet)) if (inet_pton(AF_INET, str, &subnet) <= 0)
return; return;
strnkcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ); 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; return;
if (!is_permitted(cl->ifnam)) if (!is_permitted(cl->ifnam))
return; return;
if (!inet_pton(AF_INET, str, &router)) if (inet_pton(AF_INET, str, &router) <= 0)
return; return;
memset(&rt, 0, sizeof(struct rtentry)); memset(&rt, 0, sizeof(struct rtentry));
@ -315,7 +315,7 @@ void perform_broadcast(struct ifchd_client *cl, const char *str, size_t len)
return; return;
if (!is_permitted(cl->ifnam)) if (!is_permitted(cl->ifnam))
return; return;
if (!inet_pton(AF_INET, str, &broadcast)) if (inet_pton(AF_INET, str, &broadcast) <= 0)
return; return;
strnkcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ); strnkcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ);