netstat: was using buffers one byte short for scanf (no place for NUL). fixing
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 28 Oct 2010 00:36:17 +0000 (02:36 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 28 Oct 2010 00:36:17 +0000 (02:36 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/netstat.c

index 485a7d1919f1dda862d069d7e40079919ff019e0..2a83af3ace7fac2ec187367a892b50cacee4a43d 100644 (file)
@@ -395,11 +395,14 @@ struct inet_params {
 static int scan_inet_proc_line(struct inet_params *param, char *line)
 {
        int num;
-       char local_addr[64], rem_addr[64];
+       /* IPv6 /proc files use 32-char hex representation
+        * of IPv6 address, followed by :PORT_IN_HEX
+        */
+       char local_addr[33], rem_addr[33]; /* 32 + 1 for NUL */
 
        num = sscanf(line,
-                       "%*d: %64[0-9A-Fa-f]:%X "
-                       "%64[0-9A-Fa-f]:%X %X "
+                       "%*d: %32[0-9A-Fa-f]:%X "
+                       "%32[0-9A-Fa-f]:%X %X "
                        "%lX:%lX %*X:%*X "
                        "%*X %d %*d %ld ",
                        local_addr, &param->local_port,