dns.c scan_name() add more input validation
parse_answer() add remaining length check
dns_handle_packet() add remaining length check
Addresses CVE-2020-11750
Thanks to Guido Vranken <guido@guidovranken.com> for the report who
requested credit be given to 'ForAllSecure Mayhem'.
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
if (IS_COMPRESSED(l))
return offset + 2;
+ if (l + 1 > len) return -1;
len -= l + 1;
offset += l + 1;
buffer += l + 1;
struct dns_answer *a;
uint8_t *rdata;
- if (!name) {
+ if (!name || rlen < 0) {
fprintf(stderr, "dropping: bad question\n");
return -1;
}
char *name = dns_consume_name(buffer, len, &b, &rlen);
struct dns_question *q;
- if (!name) {
+ if (!name || rlen < 0) {
fprintf(stderr, "dropping: bad name\n");
return;
}