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/dns_parse.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/dns_parse.c')
-rw-r--r-- | src/network/dns_parse.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/dns_parse.c b/src/network/dns_parse.c index 320df60d..7f83e791 100644 --- a/src/network/dns_parse.c +++ b/src/network/dns_parse.c @@ -1,7 +1,7 @@ #include <string.h> #include "lookup.h" -int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *), void *ctx) +int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *, int), void *ctx) { int qdcount, ancount; const unsigned char *p; @@ -26,7 +26,7 @@ int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, c p += 1 + !!*p; len = p[8]*256 + p[9]; if (len+10 > r+rlen-p) return -1; - if (callback(ctx, p[1], p+10, len, r) < 0) return -1; + if (callback(ctx, p[1], p+10, len, r, rlen) < 0) return -1; p += 10 + len; } return 0; |