detect: fix crash when stream inspect runs on UDP

Certain rules can apply to both TCP and UDP. For example 'alert dns'
rules are inspected against both TCP and UDP. This lead to the
stream inspect engine being called on a UDP packet.

This patch fixes the issue by exiting early from the stream inspect
engine if a) proto is not TCP or b) ssn is not available

Bug #2158.
pull/2811/head
Victor Julien 9 years ago
parent 6226338d5b
commit 885b8cefec

@ -281,6 +281,14 @@ int DetectEngineInspectStream(ThreadVars *tv,
{
Packet *p = det_ctx->p; /* TODO: get rid of this HACK */
/* in certain sigs, e.g. 'alert dns', which apply to both tcp and udp
* we can get called for UDP. */
if (p->proto != IPPROTO_TCP)
return DETECT_ENGINE_INSPECT_SIG_MATCH;
TcpSession *ssn = f->protoctx;
if (ssn == NULL)
return DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
if (det_ctx->stream_already_inspected)
return det_ctx->stream_last_result;
@ -291,7 +299,6 @@ int DetectEngineInspectStream(ThreadVars *tv,
&unused);
bool is_last = false;
TcpSession *ssn = f->protoctx;
if (flags & STREAM_TOSERVER) {
TcpStream *stream = &ssn->client;
if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED)

Loading…
Cancel
Save