Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 76756 - netstat option "--numeric-ports" affects host resolution
Summary: netstat option "--numeric-ports" affects host resolution
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-05 05:26 UTC by Mads Martin Joergensen
Modified: 2005-01-06 19:39 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Here's the patch attached. (net-tools-1.60-numericstuff.diff,2.16 KB, patch)
2005-01-05 05:28 UTC, Mads Martin Joergensen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mads Martin Joergensen 2005-01-05 05:26:31 UTC
According to the manual the option "--numeric-ports" should not affect host 
resolution, but it does. All connected hosts are displayed with numeric values 
instead of their FQDN.

Reproducible: Always
Steps to Reproduce:
1. netstat --numeric-ports
2.
3.
Actual Results:  
It did not display FQDN for the hosts

Expected Results:  
Displayed FQDN for the hosts

Here's a patch I made that fixes this--why can't I add attachments to this
bugzilla?

--- net-tools-1.60/netstat.c
+++ net-tools-1.60/netstat.c
@@ -850,8 +850,8 @@
        txq = 0L;
     }
     safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
-                                       flag_not), sizeof(local_addr));
-    safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not),
+                                       flag_not & FLAG_NUM_HOST),
sizeof(local_addr));
+    safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not &
FLAG_NUM_HOST),
                 sizeof(rem_addr));
     if (flag_all || (flag_lst && !rem_port) || (!flag_lst && rem_port)) {
        snprintf(buffer, sizeof(buffer), "%s",
@@ -1004,7 +1004,7 @@
     if (flag_all || (notnull(remaddr) && !flag_lst) || (!notnull(remaddr) &&
flag_lst))
     {   
         safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
-                                           flag_not), sizeof(local_addr));
+                                           flag_not & FLAG_NUM_HOST),
sizeof(local_addr));
        snprintf(buffer, sizeof(buffer), "%s",
                 get_sname(htons(local_port), "udp",
                           flag_not & FLAG_NUM_PORT));
@@ -1016,7 +1016,7 @@
        snprintf(buffer, sizeof(buffer), "%s",
                 get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
         safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
-                                         flag_not), sizeof(rem_addr));
+                                         flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
        if ((strlen(rem_addr) + strlen(buffer)) > 22)
            rem_addr[22 - strlen(buffer)] = '\0';
        strcat(rem_addr, ":");
@@ -1126,7 +1126,7 @@
                 get_sname(htons(local_port), "raw",
                           flag_not & FLAG_NUM_PORT));
         safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
-                                           flag_not), sizeof(local_addr));
+                                           flag_not & FLAG_NUM_HOST),
sizeof(local_addr));
        if ((strlen(local_addr) + strlen(buffer)) > 22)
            local_addr[22 - strlen(buffer)] = '\0';
        strcat(local_addr, ":");
@@ -1135,7 +1135,7 @@
        snprintf(buffer, sizeof(buffer), "%s",
                 get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
         safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
-                                         flag_not), sizeof(rem_addr));
+                                         flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
        if ((strlen(rem_addr) + strlen(buffer)) > 22)
            rem_addr[22 - strlen(buffer)] = '\0';
        strcat(rem_addr, ":");
Comment 1 Mads Martin Joergensen 2005-01-05 05:28:25 UTC
Created attachment 47695 [details, diff]
Here's the patch attached.

So, I could add attachments ;-)
Comment 2 Mads Martin Joergensen 2005-01-05 05:29:48 UTC
I've sent it upstream already.
Comment 3 rob holland (RETIRED) gentoo-dev 2005-01-06 06:46:39 UTC
tested and reviewed.

*stamp of approval*
Comment 4 SpanKY gentoo-dev 2005-01-06 19:39:52 UTC
added to net-tools-1.60-r10, thanks :)