public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fweimer at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug network/29305] New: Inefficient buffer space usage in nss_dns for gethostbyname and other functions
Date: Thu, 30 Jun 2022 11:56:50 +0000	[thread overview]
Message-ID: <bug-29305-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29305

            Bug ID: 29305
           Summary: Inefficient buffer space usage in nss_dns for
                    gethostbyname and other functions
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
          Assignee: unassigned at sourceware dot org
          Reporter: fweimer at redhat dot com
  Target Milestone: ---

A typical response buffer looks like this:

00000000: e71b 0b01 0000 0000 141c 0b01 0000 0000  ................
00000010: 671c 0b01 0000 0000 0000 0000 0000 0000  g...............
00000020: 3a3a 3100 2020 2020 2020 2020 6c6f 6361  ::1.        loca
00000030: 6c68 6f73 7400 6c6f 6361 6c68 6f73 742e  lhost.localhost.
00000040: 6c6f 6361 6c64 6f6d 6169 6e00 6c6f 6361  localdomain.loca
00000050: 6c68 6f73 7436 006c 6f63 616c 686f 7374  lhost6.localhost
00000060: 362e 6c6f 6361 6c64 6f6d 6169 6e36 0000  6.localdomain6..
00000070: 561a 0b01 0000 0000 6c1a 0b01 0000 0000  V.......l.......
00000080: 771a 0b01 0000 0000 0000 0000 0000 0000  w...............
00000090: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000a0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000b0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000c0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000d0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000e0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000000f0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000100: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000110: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000120: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000130: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000140: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000150: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000160: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000170: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000180: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
00000190: d01c 0b01 0000 0000 0000 0000 0000 0000  ................
000001a0: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
000001b0: 5858 5858 5858 5858 7777 772e 7265 6468  XXXXXXXXwww.redh
000001c0: 6174 2e63 6f6d 0077 7777 2e72 6564 6861  at.com.www.redha
000001d0: 742e 636f 6d00 6473 2d77 7777 2e72 6564  t.com.ds-www.red
000001e0: 6861 742e 636f 6d2e 6564 6765 6b65 792e  hat.com.edgekey.
000001f0: 6e65 7400 6473 2d77 7777 2e72 6564 6861  net.ds-www.redha
00000200: 742e 636f 6d2e 6564 6765 6b65 792e 6e65  t.com.edgekey.ne
00000210: 7400 6473 2d77 7777 2e72 6564 6861 742e  t.ds-www.redhat.
00000220: 636f 6d2e 6564 6765 6b65 792e 6e65 742e  com.edgekey.net.
00000230: 676c 6f62 616c 7265 6469 722e 616b 6164  globalredir.akad
00000240: 6e73 2e6e 6574 0064 732d 7777 772e 7265  ns.net.ds-www.re
00000250: 6468 6174 2e63 6f6d 2e65 6467 656b 6579  dhat.com.edgekey
00000260: 2e6e 6574 2e67 6c6f 6261 6c72 6564 6972  .net.globalredir
00000270: 2e61 6b61 646e 732e 6e65 7400 6533 3339  .akadns.net.e339
00000280: 362e 6473 6378 2e61 6b61 6d61 6965 6467  6.dscx.akamaiedg
00000290: 652e 6e65 7400 6533 3339 362e 6473 6378  e.net.e3396.dscx
000002a0: 2e61 6b61 6d61 6965 6467 652e 6e65 7400  .akamaiedge.net.
000002b0: 1700 57ba                                ..W.

This roughly corresponds to the following DNS packet:

; <<>> DiG 9.16.29-RH <<>> www.redhat.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35698
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1220
; COOKIE: 278a93776c2c45bbf190f68462bd8e694ae55e8c652b2a09 (good)
;; QUESTION SECTION:
;www.redhat.com.                        IN      A

;; ANSWER SECTION:
www.redhat.com.         300     IN      CNAME   ds-www.redhat.com.edgekey.net.
ds-www.redhat.com.edgekey.net. 15029 IN CNAME  
ds-www.redhat.com.edgekey.net.globalredir.akadns.net.
ds-www.redhat.com.edgekey.net.globalredir.akadns.net. 628 IN CNAME
e3396.dscx.akamaiedge.net.
e3396.dscx.akamaiedge.net. 14   IN      A       23.0.87.186

;; Query time: 26 msec
;; MSG SIZE  rcvd: 229

There are a bunch of gaps that are never written (the /etc/hosts contents
before the XXX and the XXX themselves). And the names of CNAME aliases are
stored twice.

If gethostbyname_r starts out with a small buffer, this results in pointless
extra DNS queries.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2022-06-30 11:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 11:56 fweimer at redhat dot com [this message]
2022-07-04 16:22 ` [Bug network/29305] " fweimer at redhat dot com
2022-08-30  8:04 ` cvs-commit at gcc dot gnu.org
2022-08-30  8:16 ` fweimer at redhat dot com
2022-09-13 11:23 ` cvs-commit at gcc dot gnu.org
2022-09-13 11:24 ` cvs-commit at gcc dot gnu.org
2022-09-20 11:07 ` cvs-commit at gcc dot gnu.org
2022-09-21 18:01 ` cvs-commit at gcc dot gnu.org

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=bug-29305-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).