From d7cae0a753c49abead5eb0d241bfe8a0d311d54a Mon Sep 17 00:00:00 2001 From: david Date: Sat, 7 Nov 2009 02:03:07 +0000 Subject: [PATCH] Fix the test for an IPv4 packet in readip_pcap. It was checking this condition: (*p & 0x40) == 0x40 But that doesn't check that the upper half of the byte is 4. It's true for 4, 5, 6, 7, 12, 13, 14, and 15. I changed it to (*p & 0xF0) == 0x40 --- tcpip.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcpip.cc b/tcpip.cc index 860d527ff..8211c7197 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -2342,7 +2342,7 @@ char *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec, } p += offset; } - if (!p || (*p & 0x40) != 0x40) { + if (!p || (*p & 0xF0) != 0x40) { /* Should we timeout? */ if (to_usec == 0) { timedout = 1; @@ -2353,7 +2353,7 @@ char *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec, } } } - } while (!timedout && (!p || (*p & 0x40) != 0x40)); /* Go until we get IPv4 packet */ + } while (!timedout && (!p || (*p & 0xF0) != 0x40)); /* Go until we get IPv4 packet */ if (timedout) { *len = 0;