#if HAVE_AFINET6 -> #ifdef HAVE_AFINET6
[oweals/busybox.git] / networking / netstat.c
index bc5c6197419e8b1f9e43347afd4635d193bff5d7..3dad57a40e97071ced3f6c91814893836ff173d2 100644 (file)
@@ -496,7 +496,6 @@ static void unix_do_one(int nr, const char *line)
 
 static void do_info(const char *file, const char *name, void (*proc)(int, const char *))
 {
-       char buffer[8192];
        int lnr = 0;
        FILE *procinfo;
 
@@ -505,12 +504,15 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const
                if (errno != ENOENT) {
                        perror(file);
                } else {
-               bb_error_msg("no support for `%s' on this system", name);
+                       bb_error_msg("no support for '%s' on this system", name);
                }
        } else {
                do {
-                       if (fgets(buffer, sizeof(buffer), procinfo))
+                       char *buffer = xmalloc_fgets(procinfo);
+                       if (buffer) {
                                (proc)(lnr++, buffer);
+                               free(buffer);
+                       }
                } while (!feof(procinfo));
                fclose(procinfo);
        }
@@ -573,7 +575,7 @@ int netstat_main(int argc, char **argv)
                        else
                                printf("(w/o servers)");
                }
-               printf("\nProto Recv-Q Send-Q Local Address           Foreign Address         State      \n");
+               printf("\nProto Recv-Q Send-Q Local Address           Foreign Address         State\n");
        }
        if (inet && flags&NETSTAT_TCP)
                do_info(_PATH_PROCNET_TCP,"AF INET (tcp)",tcp_do_one);