ALT Linux repos
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
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);
}