Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37634363
en ru br
ALT Linux repos
S:20221126-alt1
5.0: 20071127-alt4
4.1: 20071127-alt0.M41.1
4.0: 20020927-alt4.2
3.0: 20020927-alt2

Group :: Networking/Other
RPM: iputils

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: iputils-ss020927-rh-owl-cache-reverse-lookups.patch
Download


--- iputils/ping.c.orig	Fri Sep 20 15:08:11 2002
+++ iputils/ping.c	Wed Oct 15 12:38:55 2003
@@ -1123,7 +1123,13 @@
 pr_addr(__u32 addr)
 {
 	struct hostent *hp;
-	static char buf[4096];
+	static char buf[256 + 32];
+	static __u32 prevaddr;
+	static int cached = 0;
+
+	/* Return previous result if same input (avoid multiple lookups) */
+	if (cached && addr == prevaddr)
+		return(buf);
 
 	if ((options & F_NUMERIC) ||
 	    !(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
@@ -1131,6 +1137,10 @@
 	else
 		snprintf(buf, sizeof(buf), "%s (%s)", hp->h_name,
 			 inet_ntoa(*(struct in_addr *)&addr));
+
+	prevaddr = addr;
+	cached = 1;
+
 	return(buf);
 }
 
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin