mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] DNS answer buffer is too small
@ 2023-07-04  0:17 Hamish Forbes
  2023-07-04  3:29 ` Rich Felker
  0 siblings, 1 reply; 7+ messages in thread
From: Hamish Forbes @ 2023-07-04  0:17 UTC (permalink / raw)
  To: musl

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?


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

end of thread, other threads:[~2023-07-05 11:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  0:17 [musl] DNS answer buffer is too small Hamish Forbes
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

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