netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@inai.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 2/2] parser: workaround glibc-2.3.2 bug 358
Date: Tue, 15 Jan 2013 19:20:02 +0100	[thread overview]
Message-ID: <1358274002-6042-3-git-send-email-jengelh@inai.de> (raw)
In-Reply-To: <1358274002-6042-1-git-send-email-jengelh@inai.de>

glibc-2.3.2 has a bug whereby it would reject looking up services by
port number without a socket type specification. In iptables, this
manifests as:

	# iptables -A INPUT -p udp --sport 67
	iptables v1.4.16.3: Port "67" does not resolve to anything.

(The bug was found to be fixed in glibc-2.3.6.)
References: http://sourceware.org/bugzilla/show_bug.cgi?id=358
References: http://marc.info/?l=netfilter&m=135826543809613&w=2
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
 libxtables/xtoptions.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index 452e0fe..0654cb6 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -562,6 +562,20 @@ static int xtables_getportbyname(const char *name)
 	int ret;
 
 	ret = getaddrinfo(NULL, name, NULL, &res);
+	if (ret == EAI_SERVICE) {
+		/*
+		 * glibc-2.3.2 has a bug that yields EAI_SERVICE when
+		 * name is a number in string format, e.g. "67".
+		 * (http://sourceware.org/bugzilla/show_bug.cgi?id=358)
+		 * Fall back to strtoul if it is such a plain number.
+		 */
+		char *end;
+
+		ret = strtoul(name, &end, 10);
+		if (name != end && *end == '\0')
+			return ret;
+		return -1;
+	}
 	if (ret < 0)
 		return -1;
 	ret = -1;
-- 
1.7.10.4


  parent reply	other threads:[~2013-01-15 18:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 18:20 Build fixes for old Linuxes Jan Engelhardt
2013-01-15 18:20 ` [PATCH 1/2] build: fix libiptc build failure on old linux-glibc-devel headers Jan Engelhardt
2013-01-15 18:20 ` Jan Engelhardt [this message]
2013-01-18  0:44 ` Build fixes for old Linuxes Pablo Neira Ayuso
2013-01-18  1:29   ` Jan Engelhardt
2013-01-18  2:06     ` Pablo Neira Ayuso
2013-01-21 16:29       ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358274002-6042-3-git-send-email-jengelh@inai.de \
    --to=jengelh@inai.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).