From b30cdb51a56a7965525febe8e9319e02d5ccd4ba Mon Sep 17 00:00:00 2001 From: Martine Lenders <mail@martine-lenders.eu> Date: Tue, 29 Jan 2019 19:10:36 +0100 Subject: [PATCH] sock_dns: correctly report too short messages --- sys/net/application_layer/dns/dns.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/net/application_layer/dns/dns.c b/sys/net/application_layer/dns/dns.c index 639b30f511..cf82e10a83 100644 --- a/sys/net/application_layer/dns/dns.c +++ b/sys/net/application_layer/dns/dns.c @@ -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; } } } -- GitLab