mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Hamish Forbes <>
Subject: [musl] DNS answer buffer is too small
Date: Tue, 4 Jul 2023 12:17:05 +1200	[thread overview]
Message-ID: <> (raw)

In lookup_name.c the DNS answer buffer (ABUF_SIZE) is currently
hardcoded to 768 bytes, increased from 512 after TCP DNS was

The DNS RFC is, unfortunately, not very explicit about the size of TCP
However it does have this little line:

> RFC 1035 4.2.2.
> The message is prefixed with a two byte length field which gives the message length, excluding the two byte length field.

Which you could interpret as the TCP response length is a 16bit
unsigned int, so 64K.
But that's also the raw (potentially compressed) DNS response, the
uncompressed response could be larger still.

As best I can tell (I am not a C programmer!) glibc is using a scratch
buffer which grows when the parsing function returns an ERANGE error.

If that's more complex than you want, maybe a good compromise would be
allocating 768 (or 512?) for UDP queries and expanding to 64k when a
query falls back to TCP?


             reply	other threads:[~2023-07-04  0:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04  0:17 Hamish Forbes [this message]
2023-07-04  3:29 ` Rich Felker
     [not found]   ` <>
2023-07-04  4:19     ` Hamish Forbes
2023-07-04 16:07       ` Rich Felker
2023-07-05  0:18         ` Hamish Forbes
2023-07-05  3:41           ` Rich Felker
2023-07-05 11:24             ` A. Wilcox

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:

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

  git send-email \
    --in-reply-to='' \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

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).