1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #10896 from miri64/sock_dns/fix/too-small-msg-error

sock_dns: correctly report too short messages
This commit is contained in:
Martine Lenders 2019-01-29 23:43:53 +01:00 committed by GitHub
commit 1481239bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,9 +221,15 @@ int sock_dns_query(const char *domain_name, void *addr_out, int family)
continue;
}
res = sock_udp_recv(&sock_dns, reply_buf, sizeof(reply_buf), 1000000LU, NULL);
if ((res > 0) && (res > (int)DNS_MIN_REPLY_LEN)) {
if ((res = _parse_dns_reply(reply_buf, res, addr_out, family)) > 0) {
goto out;
if (res > 0) {
if (res > (int)DNS_MIN_REPLY_LEN) {
if ((res = _parse_dns_reply(reply_buf, res, addr_out,
family)) > 0) {
goto out;
}
}
else {
res = -EBADMSG;
}
}
}