Consider cap len when forwarding into packet analysis.

When forwarding into packet analysis from TCP or UDP, the protocol's
length fields were trusted. This might be dangerous in case of truncated
packets.
This commit is contained in:
Jan Grashoefer 2023-03-30 15:47:01 +02:00
parent 136d54a68e
commit fb2042ca76
3 changed files with 6 additions and 4 deletions

View file

@ -223,7 +223,7 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
// port here because the orig/resp should have already swapped around based on
// likely_server_ports. This also prevents us from processing things twice if protocol
// detection has to be used.
ForwardPacket(len, data, pkt, ntohs(c->RespPort()));
ForwardPacket(std::min(len, remaining), data, pkt, ntohs(c->RespPort()));
// Also try sending it into session analysis.
if ( remaining >= len )