1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

dns_msg: skip RDLENGTH_LENGTH field when skipping record

fixes #20355
This commit is contained in:
Benjamin Valentin 2024-09-09 11:57:15 +02:00
parent 24ad7e72c8
commit 74356c9737

View File

@ -168,6 +168,11 @@ int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
bufpos += RR_TTL_LENGTH;
unsigned addrlen = ntohs(_get_short(bufpos));
bufpos += RR_RDLENGTH_LENGTH;
if ((bufpos + addrlen) > buflim) {
return -EBADMSG;
}
/* skip unwanted answers */
if ((class != DNS_CLASS_IN) ||
((_type == DNS_TYPE_A) && (family == AF_INET6)) ||
@ -189,10 +194,6 @@ int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
(family == AF_UNSPEC))) {
return -EBADMSG;
}
bufpos += RR_RDLENGTH_LENGTH;
if ((bufpos + addrlen) > buflim) {
return -EBADMSG;
}
memcpy(addr_out, bufpos, addrlen);
return addrlen;