--- a/src/common/pcap-file.cc Mon Apr 19 08:37:27 2010 -0700
+++ b/src/common/pcap-file.cc Mon Apr 19 08:39:31 2010 -0700
@@ -417,6 +417,11 @@
m_file.read ((char *)&header.m_inclLen, sizeof(header.m_inclLen));
m_file.read ((char *)&header.m_origLen, sizeof(header.m_origLen));
+ if (m_file.fail ())
+ {
+ return;
+ }
+
if (m_swapMode)
{
Swap (&header, &header);
@@ -470,12 +475,18 @@
uint32_t readLen1, readLen2;
bool diff = false;
- while (!pcap1.Eof () && !pcap2.Eof ()
- && !pcap1.Fail () && !pcap2.Fail ())
+ while (!pcap1.Eof () && !pcap2.Eof ())
{
pcap1.Read (data1, snapLen, tsSec1, tsUsec1, inclLen1, origLen1, readLen1);
pcap2.Read (data2, snapLen, tsSec2, tsUsec2, inclLen2, origLen2, readLen2);
+ bool bad = pcap1.Fail () || pcap2.Fail ();
+ if (bad)
+ {
+ diff = true;
+ break;
+ }
+
if (tsSec1 != tsSec2 || tsUsec1 != tsUsec2)
{
diff = true; // Next packet timestamps do not match