Add a check for null packet data in pcap IOSource

Some libpcaps (observed in Myricom's) may claim to have read a packet,
but either did not really read a packet or at least provide no way
to access its contents, so this adds a check for null-data to
handle those cases.
This commit is contained in:
Jon Siwek 2021-04-08 15:09:41 -07:00
parent 25dcf210b1
commit 77cf68fda7

View file

@ -220,6 +220,14 @@ bool PcapSource::ExtractNextPacket(Packet* pkt)
return false; return false;
case 1: case 1:
// Read a packet without problem. // Read a packet without problem.
// Although, some libpcaps may claim to have read a packet, but either did
// not really read a packet or at least provide no way to access its
// contents, so the following check for null-data helps handle those cases.
if ( ! data )
{
reporter->Weird("pcap_null_data_packet");
return false;
}
break; break;
default: default:
reporter->InternalError("unhandled pcap_next_ex return value: %d", res); reporter->InternalError("unhandled pcap_next_ex return value: %d", res);