2011-12-06 18:15:09 +00:00
|
|
|
diff -up net-tools-1.60/arp.c.fgets net-tools-1.60/arp.c
|
|
|
|
--- net-tools-1.60/arp.c.fgets 2011-12-05 16:34:16.000000000 +0100
|
|
|
|
+++ net-tools-1.60/arp.c 2011-12-05 16:54:52.683352733 +0100
|
|
|
|
@@ -558,18 +558,21 @@ static int arp_show(char *name)
|
2006-03-16 21:22:44 +00:00
|
|
|
perror(_PATH_PROCNET_ARP);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
+ /* Count number of entries, in case file changes */
|
|
|
|
+ for (entries = 0; fgets(line, sizeof(line), fp); entries++);
|
|
|
|
+ entries--;
|
|
|
|
+ fseek (fp, 0L, SEEK_SET);
|
|
|
|
/* Bypass header -- read until newline */
|
|
|
|
if (fgets(line, sizeof(line), fp) != (char *) NULL) {
|
|
|
|
strcpy(mask, "-");
|
|
|
|
strcpy(dev, "-");
|
|
|
|
/* Read the ARP cache entries. */
|
|
|
|
- for (; fgets(line, sizeof(line), fp);) {
|
2011-12-06 18:15:09 +00:00
|
|
|
- num = sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n",
|
2006-03-16 21:22:44 +00:00
|
|
|
- ip, &type, &flags, hwa, mask, dev);
|
|
|
|
- if (num < 4)
|
|
|
|
+ for (num = 0; num < entries; num++) {
|
|
|
|
+ fgets(line, sizeof(line), fp);
|
2011-12-06 18:15:09 +00:00
|
|
|
+ if (sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n",
|
2006-03-16 21:22:44 +00:00
|
|
|
+ ip, &type, &flags, hwa, mask, dev) < 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
- entries++;
|
|
|
|
/* if the user specified hw-type differs, skip it */
|
|
|
|
if (hw_set && (type != hw->type))
|
|
|
|
continue;
|