Skip to contentSkip to conversation

libxtables: fix getaddrinfo return value usage

PATCH Applied Domen Puncer 2 participants 6 messages Jun 10, 2014 – Jun 16, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxtables: fix getaddrinfo return value usage

getaddrinfo return value on error can also be positive.

---
 libxtables/xtoptions.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libxtables/xtoptions.c +3 -3
index 9b4c5aa..d26d2f8 100644
@@ -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),
#1 lore raw
Quoted 1 line · Domen Puncer

getaddrinfo return value on error can also be positive.

At quick glance, all EAI_* that I see are negative.

What problem are you experience? What case are you trying to catch?

Thanks.

#2 lore raw
Quoted 4 lines · Pablo Neira Ayuso
Quoted 1 line · Domen Puncer

getaddrinfo return value on error can also be positive.

At quick glance, all EAI_* that I see are negative.

You don't see all of them :-)
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.

Quoted 5 lines

What problem are you experience? What case are you trying to catch?

Thanks.

#3 lore raw
Quoted 11 lines · Domen Puncer
Quoted 4 lines · Pablo Neira Ayuso
Quoted 1 line · Domen Puncer

getaddrinfo return value on error can also be positive.

At quick glance, all EAI_* that I see are negative.

You don't see all of them :-)
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 */

I suspected something like this..

Please, next time include this in the patch description since the beginning, thanks.

Quoted 1 line

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

It sounds like a reasonable assumption to me.

Do you have more patches like this in your queue?

#4 lore raw
Quoted 13 lines · Pablo Neira Ayuso
Quoted 11 lines · Domen Puncer
Quoted 4 lines · Pablo Neira Ayuso
Quoted 1 line · Domen Puncer

getaddrinfo return value on error can also be positive.

At quick glance, all EAI_* that I see are negative.

You don't see all of them :-)
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 */

Quoted 4 lines

I suspected something like this..

Please, next time include this in the patch description since the beginning, thanks.

OK. Will do so.

Quoted 6 lines
Quoted 2 lines

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

It sounds like a reasonable assumption to me.

Do you have more patches like this in your queue?

Sorry, this was just a one-off.

Best regards,
Domen

maintainer Applied
#5 lore raw
Quoted 14 lines · Domen Puncer
Quoted 13 lines · Pablo Neira Ayuso
Quoted 11 lines · Domen Puncer
Quoted 4 lines · Pablo Neira Ayuso
Quoted 1 line · Domen Puncer

getaddrinfo return value on error can also be positive.

At quick glance, all EAI_* that I see are negative.

You don't see all of them :-)
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 */

Quoted 6 lines
Quoted 4 lines

I suspected something like this..

Please, next time include this in the patch description since the beginning, thanks.

OK. Will do so.

Applied. I have appended the information above into the description.