From d509a7807430c29cf57905239586920aeaa85c5c Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 19 May 2020 13:57:45 +0200 Subject: [PATCH] http: handles gaps ie data=NULL and len>0 from libhtp callbacks --- src/app-layer-htp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index cc0a12cadb..a573c32300 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -1777,7 +1777,7 @@ static int HTPCallbackRequestBodyData(htp_tx_data_t *d) if (!(SC_ATOMIC_GET(htp_config_flags) & HTP_REQUIRE_REQUEST_BODY)) SCReturnInt(HTP_OK); - if (d->data == NULL || d->len == 0) + if (d->len == 0) SCReturnInt(HTP_OK); #ifdef PRINT @@ -1909,7 +1909,7 @@ static int HTPCallbackResponseBodyData(htp_tx_data_t *d) if (!(SC_ATOMIC_GET(htp_config_flags) & HTP_REQUIRE_RESPONSE_BODY)) SCReturnInt(HTP_OK); - if (d->data == NULL || d->len == 0) + if (d->len == 0) SCReturnInt(HTP_OK); HtpState *hstate = htp_connp_get_user_data(d->tx->connp); @@ -3093,6 +3093,9 @@ void RegisterHTPParsers(void) AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOCLIENT, HTPHandleResponseData); SC_ATOMIC_INIT(htp_config_flags); + /* This parser accepts gaps. */ + AppLayerParserRegisterOptionFlags( + IPPROTO_TCP, ALPROTO_HTTP, APP_LAYER_PARSER_OPT_ACCEPT_GAPS); AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_TOCLIENT); HTPConfigure();