branch merge
authorCraig Dowell <craigdo@ee.washington.edu>
Mon, 19 Apr 2010 08:39:31 -0700
changeset 6246 c21414b217d3
parent 6245 a88bde26913e (current diff)
parent 6244 ec4b512688d8 (diff)
child 6247 ab7f2498373a
branch merge
--- 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