diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2023-01-29 19:46:51 +0300 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2023-02-27 10:03:06 -0500 |
commit | 9b132e556774c744f9052581d2d8d0fab417e97c (patch) | |
tree | cbb516502c92f69bb6b01c82dbb7c30fed845c56 /src/network/getnameinfo.c | |
parent | 12590c8bbd04ea484cee86812e2258fbdfca0e59 (diff) | |
download | musl-9b132e556774c744f9052581d2d8d0fab417e97c.tar.gz musl-9b132e556774c744f9052581d2d8d0fab417e97c.tar.bz2 musl-9b132e556774c744f9052581d2d8d0fab417e97c.tar.xz musl-9b132e556774c744f9052581d2d8d0fab417e97c.zip |
prevent CNAME/PTR parsing from reading data past the response end
DNS parsing callbacks pass the response buffer end instead of the actual
response end to dn_expand, so a malformed DNS response can use message
compression to make dn_expand jump past the response end and attempt to
parse uninitialized parts of that buffer, which might succeed and return
garbage.
Diffstat (limited to 'src/network/getnameinfo.c')
-rw-r--r-- | src/network/getnameinfo.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c index 949e1811..080d3c06 100644 --- a/src/network/getnameinfo.c +++ b/src/network/getnameinfo.c @@ -108,10 +108,10 @@ static void reverse_services(char *buf, int port, int dgram) __fclose_ca(f); } -static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet) +static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet, int plen) { if (rr != RR_PTR) return 0; - if (__dn_expand(packet, (const unsigned char *)packet + 512, + if (__dn_expand(packet, (const unsigned char *)packet + plen, data, c, 256) <= 0) *(char *)c = 0; return 0; |