diff options
author | wollman <wollman@FreeBSD.org> | 1995-08-29 17:49:04 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1995-08-29 17:49:04 +0000 |
commit | 895b868d39f22c02ca6271c668edc695ca57461b (patch) | |
tree | f8d4daec19f0eb36ecdcded8ac33c25bde91538d /sys/netinet | |
parent | 11a83dc413b4c43ec0f45da657b88499bbc6a6a3 (diff) | |
download | FreeBSD-src-895b868d39f22c02ca6271c668edc695ca57461b.zip FreeBSD-src-895b868d39f22c02ca6271c668edc695ca57461b.tar.gz |
Fix long-standing bug in ICMPPRINTFS code where NTOHL was used instead
of ntohl for printing IP addresses, by instead substituting inet_ntoa()
to produce human-readable output.
Obtained from: 4.4-Lite-2
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_icmp.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 4b203f5..14b763e 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 - * $Id: ip_icmp.c,v 1.7 1995/05/30 08:09:42 rgrimes Exp $ + * $Id: ip_icmp.c,v 1.8 1995/07/10 16:16:00 wollman Exp $ */ #include <sys/param.h> @@ -194,10 +194,12 @@ icmp_input(m, hlen) * that not corrupted and of at least minimum length. */ #ifdef ICMPPRINTFS - if (icmpprintfs) - printf("icmp_input from %lx to %lx, len %d\n", - ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), - icmplen); + if (icmpprintfs) { + char buf[4 * sizeof "123"]; + strcpy(buf, inet_ntoa(ip->ip_src)); + printf("icmp_input from %s to %s, len %d\n", + buf, inet_ntoa(ip->ip_dst), icmplen); + } #endif if (icmplen < ICMP_MINLEN) { icmpstat.icps_tooshort++; @@ -381,10 +383,13 @@ reflect: icmpgw.sin_addr = ip->ip_src; icmpdst.sin_addr = icp->icmp_gwaddr; #ifdef ICMPPRINTFS - if (icmpprintfs) - printf("redirect dst %lx to %lx\n", - NTOHL(icp->icmp_ip.ip_dst.s_addr), - NTOHL(icp->icmp_gwaddr.s_addr)); + if (icmpprintfs) { + char buf[4 * sizeof "123"]; + strcpy(buf, inet_ntoa(icp->icmp_ip.ip_dst)); + + printf("redirect dst %s to %s\n", + buf, inet_ntoa(icp->icmp_gwaddr)); + } #endif icmpsrc.sin_addr = icp->icmp_ip.ip_dst; rtredirect((struct sockaddr *)&icmpsrc, @@ -562,9 +567,12 @@ icmp_send(m, opts) m->m_data -= hlen; m->m_len += hlen; #ifdef ICMPPRINTFS - if (icmpprintfs) - printf("icmp_send dst %lx src %lx\n", - NTOHL(ip->ip_dst.s_addr), NTOHL(ip->ip_src.s_addr)); + if (icmpprintfs) { + char buf[4 * sizeof "123"]; + strcpy(buf, inet_ntoa(ip->ip_dst)); + printf("icmp_send dst %s src %s\n", + buf, inet_ntoa(ip->ip_src)); + } #endif (void) ip_output(m, opts, NULL, 0, NULL); } |