[net-tools/f16] netstat_stop_trim.patch: don't truncate IPV6 UDP sockets (#732984)

Jiří Popelka jpopelka at fedoraproject.org
Wed Aug 24 12:13:28 UTC 2011


commit 540eb63121bdc6a2e6104c8fe3eb4b637cfa92b1
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Wed Aug 24 14:09:38 2011 +0200

    netstat_stop_trim.patch: don't truncate IPV6 UDP sockets (#732984)

 net-tools-1.60-netstat_stop_trim.patch |   96 ++++++++++++++++++++++++-------
 net-tools.spec                         |    5 +-
 2 files changed, 78 insertions(+), 23 deletions(-)
---
diff --git a/net-tools-1.60-netstat_stop_trim.patch b/net-tools-1.60-netstat_stop_trim.patch
index fcffcaa..003aef9 100644
--- a/net-tools-1.60-netstat_stop_trim.patch
+++ b/net-tools-1.60-netstat_stop_trim.patch
@@ -1,6 +1,7 @@
---- net-tools-1.60/man/en_US/netstat.8.old	2006-02-10 11:18:11.000000000 +0100
-+++ net-tools-1.60/man/en_US/netstat.8	2006-02-10 11:22:19.000000000 +0100
-@@ -176,6 +176,10 @@
+diff -up net-tools-1.60/man/en_US/netstat.8.trim net-tools-1.60/man/en_US/netstat.8
+--- net-tools-1.60/man/en_US/netstat.8.trim	2011-08-24 13:56:54.303033055 +0200
++++ net-tools-1.60/man/en_US/netstat.8	2011-08-24 13:56:54.475030422 +0200
+@@ -185,6 +185,10 @@ option, show interfaces that are not mar
  Print routing information from the FIB.  (This is the default.)
  .SS "\-C"
  Print routing information from the route cache.
@@ -11,9 +12,10 @@
  .SS delay
  Netstat will cycle printing through statistics every 
  .B delay 
---- net-tools-1.60/netstat.c.old	2006-02-10 11:18:12.000000000 +0100
-+++ net-tools-1.60/netstat.c	2006-02-10 11:13:50.000000000 +0100
-@@ -157,6 +157,9 @@
+diff -up net-tools-1.60/netstat.c.trim net-tools-1.60/netstat.c
+--- net-tools-1.60/netstat.c.trim	2011-08-24 13:56:54.472030469 +0200
++++ net-tools-1.60/netstat.c	2011-08-24 13:56:54.477030390 +0200
+@@ -157,6 +157,9 @@ int flag_prg = 0;
  int flag_arg = 0;
  int flag_ver = 0;
  int flag_selinux = 0;
@@ -23,7 +25,7 @@
  
  FILE *procinfo;
  
-@@ -980,16 +983,20 @@
+@@ -983,16 +986,20 @@ static void tcp_do_one(int lnr, const ch
  		 get_sname(htons(local_port), "tcp",
  			   flag_not & FLAG_NUM_PORT));
  
@@ -49,7 +51,69 @@
  
  	strcat(rem_addr, ":");
  	strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
-@@ -1776,6 +1783,7 @@
+@@ -1133,8 +1140,10 @@ static void udp_do_one(int lnr, const ch
+ 	snprintf(buffer, sizeof(buffer), "%s",
+ 		 get_sname(htons(local_port), "udp",
+ 			   flag_not & FLAG_NUM_PORT));
+-	if ((strlen(local_addr) + strlen(buffer)) >= 27)
+-	    local_addr[22 - strlen(buffer)] = '\0';
++	if (!flag_trim) {
++	    if ((strlen(local_addr) + strlen(buffer)) >= 27)
++		local_addr[27 - strlen(buffer)] = '\0';
++	}
+ 	strcat(local_addr, ":");
+ 	strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
+ 
+@@ -1142,8 +1151,10 @@ static void udp_do_one(int lnr, const ch
+ 		 get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
+         safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, 
+ 					  flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
+-	if ((strlen(rem_addr) + strlen(buffer)) >= 27)
+-	    rem_addr[22 - strlen(buffer)] = '\0';
++	if (!flag_trim) {
++	    if ((strlen(rem_addr) + strlen(buffer)) >= 27)
++		rem_addr[27 - strlen(buffer) - 1] = '\0';
++	}
+ 	strcat(rem_addr, ":");
+ 	strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
+ 
+@@ -1252,8 +1263,10 @@ static void raw_do_one(int lnr, const ch
+ 			   flag_not & FLAG_NUM_PORT));
+         safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr, 
+ 					    flag_not & FLAG_NUM_HOST), sizeof(local_addr));
+-	if ((strlen(local_addr) + strlen(buffer)) >= 27)
+-	    local_addr[22 - strlen(buffer)] = '\0';
++	if (!flag_trim) {
++	    if ((strlen(local_addr) + strlen(buffer)) >= 27)
++		local_addr[27 - strlen(buffer)] = '\0';
++	}
+ 	strcat(local_addr, ":");
+ 	strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
+ 
+@@ -1261,8 +1274,10 @@ static void raw_do_one(int lnr, const ch
+ 		 get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
+         safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, 
+ 					  flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
+-	if ((strlen(rem_addr) + strlen(buffer)) >= 27)
+-	    rem_addr[22 - strlen(buffer)] = '\0';
++	if (!flag_trim) {
++	    if ((strlen(rem_addr) + strlen(buffer)) >= 27)
++		rem_addr[27 - strlen(buffer) - 1] = '\0';
++	}
+ 	strcat(rem_addr, ":");
+ 	strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
+ 
+@@ -1723,7 +1738,8 @@ static void usage(void)
+     fprintf(stderr, _("        -a, --all, --listening     display all sockets (default: connected)\n"));
+     fprintf(stderr, _("        -o, --timers               display timers\n"));
+     fprintf(stderr, _("        -F, --fib                  display Forwarding Information Base (default)\n"));
+-    fprintf(stderr, _("        -C, --cache                display routing cache instead of FIB\n\n"));
++    fprintf(stderr, _("        -C, --cache                display routing cache instead of FIB\n"));
++    fprintf(stderr, _("        -T, --notrim               stop trimming long addresses\n"));
+     fprintf(stderr, _("        -Z, --context              display SELinux security context for sockets\n\n"));
+ 
+     fprintf(stderr, _("  <Iface>: Name of interface to monitor/list.\n"));
+@@ -1773,6 +1789,7 @@ int main
  	{"fib", 0, 0, 'F'},
  	{"groups", 0, 0, 'g'},
  	{"context", 0, 0, 'Z'},
@@ -57,7 +121,7 @@
  	{NULL, 0, 0, 0}
      };
  
-@@ -1788,7 +1796,7 @@
+@@ -1785,7 +1802,7 @@ int main
  
      afname[0] = '\0';
  
@@ -66,7 +130,7 @@
  	switch (i) {
  	case -1:
  	    break;
-@@ -1904,6 +1912,10 @@
+@@ -1901,6 +1918,10 @@ int main
  	    usage();
  	case 's':
  	    flag_sta++;
@@ -77,15 +141,3 @@
  	}
  
      if(argc == optind + 1) {
---- net-tools-1.60/netstat.c.trim2	2006-04-06 16:12:02.000000000 +0200
-+++ net-tools-1.60/netstat.c	2006-04-06 16:18:09.000000000 +0200
-@@ -1737,7 +1737,8 @@
-     fprintf(stderr, _("        -a, --all, --listening     display all sockets (default: connected)\n"));
-     fprintf(stderr, _("        -o, --timers               display timers\n"));
-     fprintf(stderr, _("        -F, --fib                  display Forwarding Information Base (default)\n"));
--    fprintf(stderr, _("        -C, --cache                display routing cache instead of FIB\n\n"));
-+    fprintf(stderr, _("        -C, --cache                display routing cache instead of FIB\n"));
-+    fprintf(stderr, _("        -T, --notrim               stop trimming long addresses\n"));
-     fprintf(stderr, _("        -Z, --context              display SELinux security context for sockets\n\n"));
- 
-     fprintf(stderr, _("  <Iface>: Name of interface to monitor/list.\n"));
diff --git a/net-tools.spec b/net-tools.spec
index 25ff1a8..77f505d 100644
--- a/net-tools.spec
+++ b/net-tools.spec
@@ -1,7 +1,7 @@
 Summary: Basic networking tools
 Name: net-tools
 Version: 1.60
-Release: 122%{?dist}
+Release: 123%{?dist}
 License: GPL+
 Group: System Environment/Base
 URL: http://net-tools.berlios.de/
@@ -345,6 +345,9 @@ fi
 %attr(0644,root,root)   %{_unitdir}/arp-ethers.service
 
 %changelog
+* Wed Aug 24 2011 Jiri Popelka <jpopelka at redhat.com> - 1.60-123
+- Improved netstat_stop_trim.patch to not truncate IPV6 UDP sockets (#732984)
+
 * Mon Jul 04 2011 Jiri Popelka <jpopelka at redhat.com> - 1.60-122
 - Update for 2 digit Linux version numbers (#718610)
 


More information about the scm-commits mailing list