]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: fix getaddrinfo return value usage
authorDomen Puncer <domen.puncer@samsung.com>
Tue, 10 Jun 2014 13:29:49 +0000 (14:29 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 13 Jun 2014 08:49:23 +0000 (10:49 +0200)
getaddrinfo return value on error can also be positive.

On Android they're positive, e.g.:

 android-ndk-r9d/platforms/android-19/arch-arm/usr/include/netdb.h
 147 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */

And as a plus, it's not bad to conform to specs.

Signed-off-by: Domen Puncer Kugler <domen.puncer@samsung.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
libxtables/xtoptions.c

index 9b4c5aa51f87ddff2bc0117208166dbb67b5d6c0..d26d2f8b3d65d5d1aab0473d53850c75f27235fc 100644 (file)
@@ -519,7 +519,7 @@ static void xtopt_parse_host(struct xt_option_call *cb)
        int ret;
 
        ret = getaddrinfo(cb->arg, NULL, &hints, &res);
-       if (ret < 0)
+       if (ret != 0)
                xt_params->exit_err(PARAMETER_PROBLEM,
                        "getaddrinfo: %s\n", gai_strerror(ret));
 
@@ -562,7 +562,7 @@ static int xtables_getportbyname(const char *name)
        int ret;
 
        ret = getaddrinfo(NULL, name, NULL, &res);
-       if (ret < 0)
+       if (ret != 0)
                return -1;
        ret = -1;
        for (p = res; p != NULL; p = p->ai_next) {
@@ -675,7 +675,7 @@ static int xtopt_parse_mask(struct xt_option_call *cb)
        int ret;
 
        ret = getaddrinfo(cb->arg, NULL, &hints, &res);
-       if (ret < 0)
+       if (ret != 0)
                return 0;
 
        memcpy(&cb->val.hmask, xtables_sa_host(res->ai_addr, res->ai_family),