public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/5790] strange behavior of getnameinfo on multiple PTR records
Date: Mon, 25 Feb 2008 15:40:00 -0000	[thread overview]
Message-ID: <20080225153956.32073.qmail@sourceware.org> (raw)
In-Reply-To: <20080225141520.5790.leolistas@solutti.com.br>


------- Additional Comments From jakub at redhat dot com  2008-02-25 15:39 -------
The problem seems to be in resolv/nss_dns/dns-host.c.
The initial buffer is too small (1024 bytes), and getanswer_r will do:
      /* The buffer is too small.  */
    too_small:
      *errnop = ERANGE;
      *h_errnop = NETDB_INTERNAL;
      return NSS_STATUS_TRYAGAIN;
Which is the right thing that getnameinfo eventually expects:
                      while (__gethostbyaddr_r ((const char *) &in_addr,
                                                sizeof (struct in_addr),
                                                AF_INET, &th, tmpbuf,
                                                tmpbuflen, &h, &herror))
                        {
                          if (herror == NETDB_INTERNAL && errno == ERANGE)
                            tmpbuf = extend_alloca (tmpbuf, tmpbuflen,
                                                    2 * tmpbuflen);
                          else
                            break;
                        }
But, unlike _nss_dns_gethostbyname*_r, _nss_dns_gethostbyaddr*_r will overwrite
all the values:
  status = getanswer_r (host_buffer.buf, n, qbuf, T_PTR, result, buffer, buflen,
                        errnop, h_errnop, 0 /* XXX */, ttlp, NULL);
  if (host_buffer.buf != orig_host_buffer)
    free (host_buffer.buf);
  if (status != NSS_STATUS_SUCCESS)
    {
      *h_errnop = h_errno;
      *errnop = errno;
      return status;
    }
I guess nuking the *h_errnop = h_errno; *errnop = errno; could fix this.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5790

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


  reply	other threads:[~2008-02-25 15:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 14:16 [Bug libc/5790] New: " leolistas at solutti dot com dot br
2008-02-25 15:40 ` jakub at redhat dot com [this message]
2008-02-26 13:31 ` [Bug libc/5790] " leolistas at solutti dot com dot br
2008-03-04 15:26 ` drepper at redhat dot com
     [not found] <bug-5790-131@http.sourceware.org/bugzilla/>
2014-07-02  7:03 ` fweimer at redhat dot com

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=20080225153956.32073.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).