1.1 --- a/src/devices/emu/emu-net-device.cc Wed Jul 08 21:45:23 2009 -0700
1.2 +++ b/src/devices/emu/emu-net-device.cc Fri Jul 10 09:50:24 2009 -0700
1.3 @@ -612,6 +612,19 @@
1.4 Ptr<Packet> originalPacket = packet->Copy ();
1.5
1.6 EthernetHeader header (false);
1.7 +
1.8 + //
1.9 + // This device could be running in an environment where completely unexpected
1.10 + // kinds of packets are flying around, so we need to harden things a bit and
1.11 + // filter out packets we think are completely bogus, so we always check to see
1.12 + // that the packet is long enough to contain the header we want to remove.
1.13 + //
1.14 + if (packet->GetSize() < header.GetSerializedSize())
1.15 + {
1.16 + m_phyRxDropTrace (originalPacket);
1.17 + return;
1.18 + }
1.19 +
1.20 packet->RemoveHeader (header);
1.21
1.22 NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
1.23 @@ -628,6 +641,16 @@
1.24 if (header.GetLengthType () <= 1500)
1.25 {
1.26 LlcSnapHeader llc;
1.27 + //
1.28 + // Check to see that the packet is long enough to possibly contain the
1.29 + // header we want to remove before just naively calling.
1.30 + //
1.31 + if (packet->GetSize() < llc.GetSerializedSize())
1.32 + {
1.33 + m_phyRxDropTrace (originalPacket);
1.34 + return;
1.35 + }
1.36 +
1.37 packet->RemoveHeader (llc);
1.38 protocol = llc.GetType ();
1.39 }