Package: bing
Version: 1.1.3-2
Severity: normal

I too inadvertently then repeatedly have managed to reproduce this bug.
In my case I see 9223372036854775808 output instead of 2147483532.662ms as in 
the reported case.

I was able to reproduce it on several Internet hosts although I didn't want to 
try too often in case it triggered some security warning.

Using the host from the first bug report above for comparison:



bing -s 1000 -S 10000 localhost www.cam.ac.uk
BING    localhost (127.0.0.1) and www.cam.ac.uk (131.111.8.46)
        1000 and 10000 data bytes (144000 bits)
www.cam.ac.uk:  0.000bps  9223372036854775808.000ms 
64051194700380384.000000us/bit



I noticed that 9223372036854775808 corresponds to (1 << 63) (I am using amd64) 
which is roughly in line with the initial reports suspicion about -1.

Digging through the code, (a task I found a little challenging at first as it 
was to be written in old-school C, but persistence pays off), I discovered that 
this constant was used to indicate an uninitialised timing result.

Further digging, I noticed a function ping_and_wait() that would return if 
icmp_recv() indicated a time-out, but did not inform the caller of this 
situation.  It seems that if the ICMP_ECHOREPLY is not received in time, this 
timeout happened, and another function, pr_pack() is not called, resulting in 
the affected time information structure remaining uninitialised, causing the 
bug.

This only occurs for some hosts, so possibly the network in between is 
filtering larger ICMP packets?

My workaround is to have ping_and_wait() return a flag and then check this at 
the caller, which will print a warning and abort the current calculation as 
unachievable.

I have attached a patch against the bing.c that was installed by using apt-get 
source, please note having not done so before I am currently unfamiliar with 
the correct way to submit a patch to Debian.

thanks,
Andrew
http://blog.oldcomputerjunk.net

-- System Information:
Debian Release: 6.0.1
  APT prefers stable
  APT policy: (610, 'stable'), (600, 'stable'), (500, 'stable-updates'), (300, 
'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.39-bpo.2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bing depends on:
ii  libc6                         2.11.2-10  Embedded GNU C Library: Shared lib

bing recommends no packages.

bing suggests no packages.

-- no debconf information
913c913
< void ping_and_wait(hs, datalen, buf, buflen)
---
> int ping_and_wait(hs, datalen, buf, buflen)
944c944
< 		break;
---
> 		return 1;
949a950
> 	return 0;
1594,1595c1595,1599
< 			ping_and_wait(hs2, j,
< 				(char *)recv_packet, recv_packlen);
---
> 			if (1 == ping_and_wait(hs2, j,
> 				(char *)recv_packet, recv_packlen)) {
> 				fprintf( stderr, "bing: timed out waiting for ICMP_ECHOREPLY for length %d\n", j);
> 				break;
> 				}
1598,1599c1602,1606
< 		    ping_and_wait(hs2, datalen_big,
< 			(char *)recv_packet, recv_packlen);
---
> 		    if (1==ping_and_wait(hs2, datalen_big,
> 			(char *)recv_packet, recv_packlen)) {
> 			        fprintf( stderr, "bing: timed out waiting for final ICMP_ECHOREPLY for length %d\n", datalen_big);
> 			        break;
> 			        }

Reply via email to