public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't require DNS labels to be host names
@ 2010-10-26 12:53 Andreas Schwab
  2010-10-26 14:06 ` Ulrich Drepper
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2010-10-26 12:53 UTC (permalink / raw)
  To: libc-hacker

2010-10-26  Andreas Schwab  <schwab@redhat.com>

	[BZ #12154]
	* resolv/nss_dns/dns-host.c (getanswer_r): Don't require DNS
	labels to be host names.
	(gaih_getanswer_slice): Likewise.
---
 resolv/nss_dns/dns-host.c |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 8592183..19f6dab 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -716,7 +716,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
 	  n = -1;
 	}
 
-      if (__builtin_expect (n < 0 || (*name_ok) (bp) == 0, 0))
+      if (__builtin_expect (n < 0 || res_dnok (bp) == 0, 0))
 	{
 	  ++had_error;
 	  continue;
@@ -746,25 +746,29 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
 
       if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME)
 	{
-	  if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1])
-	    continue;
 	  n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
-	  if (__builtin_expect (n < 0 || (*name_ok) (tbuf) == 0, 0))
+	  if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0))
 	    {
 	      ++had_error;
 	      continue;
 	    }
 	  cp += n;
-	  /* Store alias.  */
-	  *ap++ = bp;
-	  n = strlen (bp) + 1;		/* For the \0.  */
-	  if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN)
+	  /* Ignore aliases that are not valid host names.  */
+	  if (res_hnok (bp))
 	    {
-	      ++had_error;
-	      continue;
+	      if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1])
+		continue;
+	      /* Store alias.  */
+	      *ap++ = bp;
+	      n = strlen (bp) + 1;		/* For the \0.  */
+	      if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN)
+		{
+		  ++had_error;
+		  continue;
+		}
+	      bp += n;
+	      linebuflen -= n;
 	    }
-	  bp += n;
-	  linebuflen -= n;
 	  /* Get canonical name.  */
 	  n = strlen (tbuf) + 1;	/* For the \0.  */
 	  if (__builtin_expect (n > linebuflen, 0))
@@ -892,6 +896,11 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
 #endif
 	case T_A:
 	case T_AAAA:
+	  if (res_hnok (bp) == 0)
+	    {
+	      had_error++;
+	      break;
+	    }
 	  if (__builtin_expect (strcasecmp (result->h_name, bp), 0) != 0)
 	    {
 	      syslog (LOG_NOTICE | LOG_AUTH, AskedForGot, result->h_name, bp);
@@ -1045,7 +1054,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 
 	  n = -1;
 	}
-      if (__builtin_expect (n < 0 || res_hnok (buffer) == 0, 0))
+      if (__builtin_expect (n < 0 || res_dnok (buffer) == 0, 0))
 	{
 	  ++had_error;
 	  continue;
@@ -1084,7 +1093,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 	{
 	  char tbuf[MAXDNAME];
 	  n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
-	  if (__builtin_expect (n < 0 || res_hnok (tbuf) == 0, 0))
+	  if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0))
 	    {
 	      ++had_error;
 	      continue;
@@ -1163,6 +1172,11 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 
       if (*firstp)
 	{
+	  if (res_hnok (canon ?: h_name) == 0)
+	    {
+	      ++had_error;
+	      continue;
+	    }
 	  if (ttl != 0 && ttlp != NULL)
 	    *ttlp = ttl;
 
-- 
1.7.2.3


-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't require DNS labels to be host names
  2010-10-26 12:53 [PATCH] Don't require DNS labels to be host names Andreas Schwab
@ 2010-10-26 14:06 ` Ulrich Drepper
  2010-10-26 15:20   ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Drepper @ 2010-10-26 14:06 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

Is this what more recent versions of libresolv do or where does this come from?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't require DNS labels to be host names
  2010-10-26 14:06 ` Ulrich Drepper
@ 2010-10-26 15:20   ` Andreas Schwab
  2010-10-26 15:25     ` Ulrich Drepper
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2010-10-26 15:20 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libc-hacker

Ulrich Drepper <drepper@gmail.com> writes:

> Is this what more recent versions of libresolv do or 

What do you mean with "more recent versions of libresolv"?

> where does this come from?

Read the bug report.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't require DNS labels to be host names
  2010-10-26 15:20   ` Andreas Schwab
@ 2010-10-26 15:25     ` Ulrich Drepper
  2010-10-26 15:42       ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Drepper @ 2010-10-26 15:25 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

On Tue, Oct 26, 2010 at 11:20, Andreas Schwab <schwab@redhat.com> wrote:
> What do you mean with "more recent versions of libresolv"?

bind releases still have libresolv.


> Read the bug report.

I did and I am not at all convinced that anything done is valid.  The
code is as it is forever.  Invalid extensions by msft or others are
still invalid and don't warrant support.


Therefore the question: how did you come up with the patch?  There are
a lot of changes and there is no detailed explanation.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't require DNS labels to be host names
  2010-10-26 15:25     ` Ulrich Drepper
@ 2010-10-26 15:42       ` Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2010-10-26 15:42 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libc-hacker

Ulrich Drepper <drepper@gmail.com> writes:

> Invalid extensions by msft

What does this have to do with msft?

> Therefore the question: how did you come up with the patch?

By fixing the bug described in the bug report.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-26 15:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 12:53 [PATCH] Don't require DNS labels to be host names Andreas Schwab
2010-10-26 14:06 ` Ulrich Drepper
2010-10-26 15:20   ` Andreas Schwab
2010-10-26 15:25     ` Ulrich Drepper
2010-10-26 15:42       ` Andreas Schwab

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 read-only IMAP folder(s) and NNTP newsgroup(s).