Hello.
nslookup(1) with explicit -type=ptr argument will not turn the
given HOST to .{in-addr,ip6}.arpa notation via make_ptr().
This is fixed by the patch below.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
From 86652da4d5852866b279a69c9171a75394e98190 Mon Sep 17 00:00:00 2001
Message-ID: <86652da4d5852866b279a69c9171a75394e98190.1759258006.git.stef...@sdaoden.eu>
From: Steffen Nurpmeso <[email protected]>
Date: Tue, 30 Sep 2025 20:38:25 +0200
Subject: [PATCH] nslookup: fix -type=ptr (explicit type given)
---
networking/nslookup.c | 52 +++++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/networking/nslookup.c b/networking/nslookup.c
index b67d354f77..2e8ca48fee 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -1171,28 +1171,6 @@ static void add_query(int type, const char *dname)
new_q->qlen = qlen;
}
-static void add_query_with_search(int type, const char *dname)
-{
- char *s;
-
- if (type == T_PTR || !G.search || strchr(dname, '.')) {
- add_query(type, dname);
- return;
- }
-
- s = G.search;
- for (;;) {
- char *fullname, *e;
-
- e = skip_non_whitespace(s);
- fullname = xasprintf("%s.%.*s", dname, (int)(e - s), s);
- add_query(type, fullname);
- s = skip_whitespace(e);
- if (!*s)
- break;
- }
-}
-
static char *make_ptr(const char *addrstr)
{
unsigned char addr[16];
@@ -1225,6 +1203,36 @@ static char *make_ptr(const char *addrstr)
return NULL;
}
+static void add_query_with_search(int type, const char *dname)
+{
+ char *s;
+
+ if (type == T_PTR) {
+ s = make_ptr(dname);
+ if(s == NULL)
+ bb_error_msg_and_die("invalid ptr HOST \"%s\"", dname);
+ add_query(type, s);
+ return;
+ }
+
+ if (!G.search || strchr(dname, '.')) {
+ add_query(type, dname);
+ return;
+ }
+
+ s = G.search;
+ for (;;) {
+ char *fullname, *e;
+
+ e = skip_non_whitespace(s);
+ fullname = xasprintf("%s.%.*s", dname, (int)(e - s), s);
+ add_query(type, fullname);
+ s = skip_whitespace(e);
+ if (!*s)
+ break;
+ }
+}
+
int nslookup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int nslookup_main(int argc UNUSED_PARAM, char **argv)
{
--
2.51.0
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox