[BusyBox 0000309]: ping -s n localhost , with n smaller then 6 results in wrong timing results

bugs at busybox.net bugs at busybox.net
Tue Nov 29 21:46:12 UTC 2005


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=309 
====================================================================== 
Reported By:                Wutje
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   309
Category:                   Networking Support
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             06-25-2005 13:08 PDT
Last Modified:              11-29-2005 13:46 PST
====================================================================== 
Summary:                    ping -s n localhost , with n smaller then 6 results
in wrong timing results
Description: 
ping -s n localhost , with n smaller then 6 results in wrong timing
results
The error is the biggest when using -s 1,

Example:

ping -s 1 localhost
PING localhost.localdomain (127.0.0.1): 1 data bytes
9 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=416459759.4 ms
9 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=416459753.1 ms
9 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=416459753.1 ms
9 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=416459753.1 ms
====================================================================== 

---------------------------------------------------------------------- 
 montezuma - 11-29-05 13:46  
---------------------------------------------------------------------- 
In networking/ping.c there appears to be a bug that is causing this issue,
or worse on some architectures/toolschains.

In the gettimeofday call the result is placed into the icmp data. The size
of struct timeval is 8. packet is declared as "char packet[datalen + 8];",
guess what happens if the datalen is < 8. The minimum datalen size should
be the size of struct timeval.

gettimeofday((struct timeval *) &packet[8], NULL); 


static void sendping(int junk)
{
	struct icmp *pkt;
	int i;
	char packet[datalen + 8];

	pkt = (struct icmp *) packet;

	pkt->icmp_type = ICMP_ECHO;
	pkt->icmp_code = 0;
	pkt->icmp_cksum = 0;
	pkt->icmp_seq = htons(ntransmitted++);
	pkt->icmp_id = myid;
	CLR(ntohs(pkt->icmp_seq) % MAX_DUP_CHK);

	gettimeofday((struct timeval *) &packet[8], NULL); 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
06-25-05 13:08  Wutje          New Issue                                    
11-29-05 13:46  montezuma      Note Added: 0000713                          
======================================================================




More information about the busybox-cvs mailing list