From: Jo-Philipp Wich Date: Thu, 27 Jun 2019 15:27:28 +0000 (+0200) Subject: nslookup: handle replies without RRs X-Git-Tag: 1_32_0~112 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8c3b520d4f937b1d1856898dec5f634b12d9cc36;p=oweals%2Fbusybox.git nslookup: handle replies without RRs Under some circumstances, a DNS reply might contain no resource records, e.g. when a valid domain is queried that does not have records of the requested type. Example with nslookup from BIND dnsutils: $ nslookup -q=SRV example.org Server: 10.11.12.13 Address: 10.11.12.13#53 Non-authoritative answer: *** Can't find example.org: No answer Currently the busybox nslookup applet simply prints nothing after the "Non-authoritative answer:" line in the same situation. This change modifies nslookup to either print "Parse error" or "No answer" diagnostics, depending on the parse_reply() return value. function old new delta send_queries 1676 1711 +35 Signed-off-by: Jo-Philipp Wich Signed-off-by: Denys Vlasenko --- diff --git a/networking/nslookup.c b/networking/nslookup.c index 8adde14b8..a7dd823f0 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -615,9 +615,15 @@ static int send_queries(struct ns *ns) G.query[qn].name, rcodes[rcode]); G.exitcode = EXIT_FAILURE; } else { - if (parse_reply(reply, recvlen) < 0) { + switch (parse_reply(reply, recvlen)) { + case -1: printf("*** Can't find %s: Parse error\n", G.query[qn].name); G.exitcode = EXIT_FAILURE; + break; + + case 0: + printf("*** Can't find %s: No answer\n", G.query[qn].name); + break; } } bb_putchar('\n');