Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37749078
en ru br
ALT Linux repos
S:1.60-alt19
5.0: 1.60-alt15
4.1: 1.60-alt13
4.0: 1.60-alt13
3.0: 1.60-alt12

Group :: System/Configuration/Networking
RPM: net-tools

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: net-tools-1.60-rh-arp-fgets.patch
Download


Fix for when arp_disp_2() is called without opt_n set.  If there is a DNS lookup, an
entry is added to /proc/net/arp after fopen(), resulting in a duplicate entry.
--- net-tools-1.60/arp.c.fgets	2005-12-10 14:52:04.000000000 -0500
+++ net-tools-1.60/arp.c	2005-12-11 00:15:59.000000000 -0500
@@ -528,7 +528,7 @@ static int arp_show(char *name)
     int type, flags;
     FILE *fp;
     char *hostname;
-    int num, entries = 0, showed = 0;
+    int num, entries, showed = 0;
 
     host[0] = '\0';
 
@@ -546,18 +546,21 @@ static int arp_show(char *name)
 	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);) {
-	    num = sscanf(line, "%s 0x%x 0x%x %100s %100s %100s\n",
-			 ip, &type, &flags, hwa, mask, dev);
-	    if (num < 4)
+	for (num = 0; num < entries; num++) {
+	    fgets(line, sizeof(line), fp);
+	    if (sscanf(line, "%s 0x%x 0x%x %100s %100s %100s\n",
+			 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;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin