diff mbox

[iptables] libxtables: fix getaddrinfo return value usage

Message ID 5397084D.8020703@samsung.com
State Accepted
Headers show

Commit Message

Domen Puncer June 10, 2014, 1:29 p.m. UTC
getaddrinfo return value on error can also be positive.

Signed-off-by: Domen Puncer Kugler <domen.puncer@samsung.com>
---
 libxtables/xtoptions.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pablo Neira Ayuso June 11, 2014, 9:37 a.m. UTC | #1
On Tue, Jun 10, 2014 at 02:29:49PM +0100, Domen Puncer wrote:
> 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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Domen Puncer June 11, 2014, 9:48 a.m. UTC | #2
On 11/06/14 10:37, Pablo Neira Ayuso wrote:
> On Tue, Jun 10, 2014 at 02:29:49PM +0100, Domen Puncer wrote:
>> 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.

> 
> What problem are you experience? What case are you trying to catch?
> 
> Thanks.
> 

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso June 11, 2014, 5:55 p.m. UTC | #3
On Wed, Jun 11, 2014 at 10:48:19AM +0100, Domen Puncer wrote:
> On 11/06/14 10:37, Pablo Neira Ayuso wrote:
> > On Tue, Jun 10, 2014 at 02:29:49PM +0100, Domen Puncer wrote:
> >> 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.

> 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?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Domen Puncer June 12, 2014, 7:01 a.m. UTC | #4
On 11/06/14 18:55, Pablo Neira Ayuso wrote:
> On Wed, Jun 11, 2014 at 10:48:19AM +0100, Domen Puncer wrote:
>> On 11/06/14 10:37, Pablo Neira Ayuso wrote:
>>> On Tue, Jun 10, 2014 at 02:29:49PM +0100, Domen Puncer wrote:
>>>> 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.

OK. Will do so.

> 
>> 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
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso June 16, 2014, 9:48 a.m. UTC | #5
On Thu, Jun 12, 2014 at 08:01:29AM +0100, Domen Puncer wrote:
> On 11/06/14 18:55, Pablo Neira Ayuso wrote:
> > On Wed, Jun 11, 2014 at 10:48:19AM +0100, Domen Puncer wrote:
> >> On 11/06/14 10:37, Pablo Neira Ayuso wrote:
> >>> On Tue, Jun 10, 2014 at 02:29:49PM +0100, Domen Puncer wrote:
> >>>> 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.
> 
> OK. Will do so.

Applied. I have appended the information above into the description.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index 9b4c5aa..d26d2f8 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -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),