[Bug 9076] Whois using a non working host for queries by default

bugzilla at busybox.net bugzilla at busybox.net
Mon Jul 4 18:21:12 UTC 2016


https://bugs.busybox.net/show_bug.cgi?id=9076

--- Comment #1 from Vito Mule <mulevito at gmail.com> ---
Disregard my previous patch, this should work better.
I added some logic to use $domain.whois-servers.net as server based on the
query's domain.


diff --git a/networking/whois.c b/networking/whois.c
index bf33033..9a73bbc 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -47,13 +47,32 @@ static void pipe_out(int fd)
 int whois_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int whois_main(int argc UNUSED_PARAM, char **argv)
 {
+
+       char *host = malloc(67 * sizeof(char));
+       char domain[49];
+       char* token;
+
        int port = 43;
-       const char *host = "whois-servers.net";
+       const char *unqualified_host = ".whois-servers.net";

        opt_complementary = "-1:p+";
        getopt32(argv, "h:p:", &host, &port);
-
        argv += optind;
+
+       if (strlen(host) < 1) {
+               size_t query_len = strlen(*argv);
+               char *str_token = malloc(query_len * sizeof(char));
+               strncpy(str_token, *argv, query_len);
+
+               token = strtok(str_token, ".");
+               while (token != NULL) {
+               strcpy(domain, token);
+            token = strtok(NULL, ".");
+            }
+        strncpy(host, domain, strlen(domain));
+        strncat(host, unqualified_host, 18);
+       }
+
        do {
                int fd = create_and_connect_stream_or_die(host, port);
                fdprintf(fd, "%s\r\n", *argv);

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list