Bug#522759: netstat: -W truncates long udp and udp6 socket addresses

Yasuhiro Abe yadiary at gmail.com
Tue Feb 23 15:44:59 UTC 2010


I also got this issue, so following patch will solve that.

$ diff -u netstat.c.20100223 netstat.c
--- netstat.c.20100223    2010-02-24 00:04:29.000000000 +0900
+++ netstat.c    2010-02-24 00:33:04.000000000 +0900
@@ -847,7 +847,7 @@

 static void udp_do_one(int lnr, const char *line)
 {
-    char buffer[8192], local_addr[64], rem_addr[64];
+    char buffer[8192], local_addr[128], rem_addr[128];
     char *udp_state, timers[64], more[512];
     int num, local_port, rem_port, d, state, timer_run, uid, timeout;
     char *protname;
@@ -944,8 +944,10 @@
     snprintf(buffer, sizeof(buffer), "%s",
          get_sname(htons(local_port), "udp",
                flag_not & FLAG_NUM_PORT));
-    if ((strlen(local_addr) + strlen(buffer)) > 22)
-        local_addr[22 - strlen(buffer)] = '\0';
+    if (!flag_wide) {
+        if ((strlen(local_addr) + strlen(buffer)) > 22)
+            local_addr[22 - strlen(buffer)] = '\0';
+    }
     strcat(local_addr, ":");
     strcat(local_addr, buffer);

@@ -953,8 +955,10 @@
          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));
-    if ((strlen(rem_addr) + strlen(buffer)) > 22)
-        rem_addr[22 - strlen(buffer)] = '\0';
+    if (!flag_wide) {
+        if ((strlen(rem_addr) + strlen(buffer)) > 22)
+            rem_addr[22 - strlen(buffer)] = '\0';
+    }
     strcat(rem_addr, ":");
     strcat(rem_addr, buffer);

----
Yasuhiro ABE
web:      http://www.yasundial.org/
twitter:  http://twitter.com/YasuhiroABE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-net-tools-maintainers/attachments/20100224/054241e2/attachment.htm>


More information about the Pkg-net-tools-maintainers mailing list