aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-31 01:39:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-31 01:39:44 +0100
commit49fd1d69babc6945175068e8fe4c85713fe5fcdb (patch)
tree013d7a396ad7bc40509c2e3aa1fc7c59a0e9ad8f
parent3c13da3dab539eac948de48640d8862857d0c8d0 (diff)
downloadbusybox-w32-49fd1d69babc6945175068e8fe4c85713fe5fcdb.tar.gz
busybox-w32-49fd1d69babc6945175068e8fe4c85713fe5fcdb.tar.bz2
busybox-w32-49fd1d69babc6945175068e8fe4c85713fe5fcdb.zip
nslookup: do not print "No answer" for NODATA replies, closes 13006
Only print when there was no answer at all. function old new delta send_queries 1834 1813 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/nslookup.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c
index 5aa2b35d2..c43ad46f3 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -349,6 +349,8 @@ static int parse_reply(const unsigned char *msg, size_t len)
349 header = (HEADER *)msg; 349 header = (HEADER *)msg;
350 if (!header->aa) 350 if (!header->aa)
351 printf("Non-authoritative answer:\n"); 351 printf("Non-authoritative answer:\n");
352 else if (option_mask32 & OPT_debug)
353 printf("Non-authoritative answer:\n" + 4);
352 354
353 if (ns_initparse(msg, len, &handle) != 0) { 355 if (ns_initparse(msg, len, &handle) != 0) {
354 //printf("Unable to parse reply: %s\n", strerror(errno)); 356 //printf("Unable to parse reply: %s\n", strerror(errno));
@@ -381,7 +383,7 @@ static int parse_reply(const unsigned char *msg, size_t len)
381 return -1; 383 return -1;
382 } 384 }
383 inet_ntop(AF_INET6, ns_rr_rdata(rr), astr, sizeof(astr)); 385 inet_ntop(AF_INET6, ns_rr_rdata(rr), astr, sizeof(astr));
384 /* bind-utils-9.11.3 uses the same format for A and AAAA answers */ 386 /* bind-utils 9.11.3 uses the same format for A and AAAA answers */
385 printf("Name:\t%s\nAddress: %s\n", ns_rr_name(rr), astr); 387 printf("Name:\t%s\nAddress: %s\n", ns_rr_name(rr), astr);
386 break; 388 break;
387#endif 389#endif
@@ -580,7 +582,7 @@ static int send_queries(struct ns *ns)
580 printf("Address:\t%s\n\n", 582 printf("Address:\t%s\n\n",
581 auto_string(xmalloc_sockaddr2dotted(&ns->lsa->u.sa)) 583 auto_string(xmalloc_sockaddr2dotted(&ns->lsa->u.sa))
582 ); 584 );
583 /* In "Address", bind-utils-9.11.3 show port after a hash: "1.2.3.4#53" */ 585 /* In "Address", bind-utils 9.11.3 show port after a hash: "1.2.3.4#53" */
584 /* Should we do the same? */ 586 /* Should we do the same? */
585 } 587 }
586 588
@@ -640,12 +642,26 @@ static int send_queries(struct ns *ns)
640 printf("*** Can't find %s: Parse error\n", G.query[qn].name); 642 printf("*** Can't find %s: Parse error\n", G.query[qn].name);
641 G.exitcode = EXIT_FAILURE; 643 G.exitcode = EXIT_FAILURE;
642 break; 644 break;
643 645 /* bind-utils 9.11.25 just says nothing in this case */
644 case 0: 646 //case 0:
645 printf("*** Can't find %s: No answer\n", G.query[qn].name); 647 // break;
646 break;
647 } 648 }
648 } 649 }
650/* NB: in case of authoritative, empty answer (NODATA), IOW: one with
651 * ns_msg_count() == 0, bind-utils 9.11.25 shows no trace of this answer
652 * (unless -debug, where it says:
653 * ------------
654 * QUESTIONS:
655 * host.com, type = AAAA, class = IN
656 * ANSWERS:
657 * AUTHORITY RECORDS:
658 * ADDITIONAL RECORDS:
659 * ------------
660 * ). Due to printing of below '\n', we do show an additional empty line.
661 * This is better than not showing any indication of this reply at all,
662 * yet maintains "compatibility". I wonder whether it's better to break compat
663 * and emit something more meaningful, e.g. print "Empty answer (NODATA)"?
664 */
649 bb_putchar('\n'); 665 bb_putchar('\n');
650 n_replies++; 666 n_replies++;
651 if (n_replies >= G.query_count) 667 if (n_replies >= G.query_count)