make sure we don't attempt to read outside of ourselves when deserializing a header for printing.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 11 Aug 2008 15:18:40 -0700
changeset 3526 076ae3766f27
parent 3525 4b8ef7da0ac3
child 3527 1548d7e3604f
make sure we don't attempt to read outside of ourselves when deserializing a header for printing.
src/common/packet-metadata.cc
--- a/src/common/packet-metadata.cc	Mon Aug 11 10:40:31 2008 -0700
+++ b/src/common/packet-metadata.cc	Mon Aug 11 15:18:40 2008 -0700
@@ -1001,9 +1001,10 @@
       item.type = PacketMetadata::Item::HEADER;
       if (!item.isFragment)
         {
-          ns3::Buffer::Iterator j = m_buffer.Begin ();
-          j.Next (m_offset);
-          item.current = j;
+          ns3::Buffer tmp = m_buffer;
+          tmp.RemoveAtStart (m_offset);
+          tmp.RemoveAtEnd (tmp.GetSize () - item.currentSize);
+          item.current = tmp.Begin ();
         }
     }
   else if (tid.IsChildOf (Trailer::GetTypeId ()))
@@ -1011,9 +1012,10 @@
       item.type = PacketMetadata::Item::TRAILER;
       if (!item.isFragment)
         {
-          ns3::Buffer::Iterator j = m_buffer.End ();
-          j.Prev (m_buffer.GetSize () - (m_offset + smallItem.size));
-          item.current = j;
+          ns3::Buffer tmp = m_buffer;
+          tmp.RemoveAtEnd (tmp.GetSize () - (m_offset + smallItem.size));
+          tmp.RemoveAtStart (tmp.GetSize () - item.currentSize);
+          item.current = tmp.End ();
         }
     }
   else