detect/http2: update buffer initialization logic

pull/8482/head
Victor Julien 4 years ago
parent 5e783a01fe
commit 158e648d87

@ -672,10 +672,9 @@ static void PrefilterMpmHttp2HNameFree(void *ptr)
SCFree(ptr); SCFree(ptr);
} }
static InspectionBuffer *GetHttp2HNameData(DetectEngineThreadCtx *det_ctx, static InspectionBuffer *GetHttp2HNameData(DetectEngineThreadCtx *det_ctx, const uint8_t flags,
const uint8_t flags, const DetectEngineTransforms *transforms, const DetectEngineTransforms *transforms, Flow *_f, const struct MpmListIdDataArgs *cbdata,
Flow *_f, const struct MpmListIdDataArgs *cbdata, int list_id)
int list_id, bool first)
{ {
SCEnter(); SCEnter();
@ -683,7 +682,7 @@ static InspectionBuffer *GetHttp2HNameData(DetectEngineThreadCtx *det_ctx,
InspectionBufferMultipleForListGet(det_ctx, list_id, cbdata->local_id); InspectionBufferMultipleForListGet(det_ctx, list_id, cbdata->local_id);
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
if (!first && buffer->inspect != NULL) if (buffer->initialized)
return buffer; return buffer;
uint32_t b_len = 0; uint32_t b_len = 0;
@ -715,8 +714,8 @@ static void PrefilterTxHttp2HName(DetectEngineThreadCtx *det_ctx, const void *pe
// loop until we get a NULL // loop until we get a NULL
struct MpmListIdDataArgs cbdata = { local_id, txv }; struct MpmListIdDataArgs cbdata = { local_id, txv };
InspectionBuffer *buffer = GetHttp2HNameData(det_ctx, flags, ctx->transforms, InspectionBuffer *buffer =
f, &cbdata, list_id, true); GetHttp2HNameData(det_ctx, flags, ctx->transforms, f, &cbdata, list_id);
if (buffer == NULL) if (buffer == NULL)
break; break;
@ -762,8 +761,8 @@ static uint8_t DetectEngineInspectHttp2HeaderName(DetectEngineCtx *de_ctx,
while (1) { while (1) {
//TODOask use MpmListIdDataArgs elsewhere //TODOask use MpmListIdDataArgs elsewhere
struct MpmListIdDataArgs cbdata = { local_id, txv, }; struct MpmListIdDataArgs cbdata = { local_id, txv, };
InspectionBuffer *buffer = GetHttp2HNameData(det_ctx, flags, InspectionBuffer *buffer =
transforms, f, &cbdata, engine->sm_list, false); GetHttp2HNameData(det_ctx, flags, transforms, f, &cbdata, engine->sm_list);
if (buffer == NULL || buffer->inspect == NULL) if (buffer == NULL || buffer->inspect == NULL)
break; break;
@ -803,10 +802,9 @@ static void PrefilterMpmHttp2HeaderFree(void *ptr)
SCFree(ptr); SCFree(ptr);
} }
static InspectionBuffer *GetHttp2HeaderData(DetectEngineThreadCtx *det_ctx, static InspectionBuffer *GetHttp2HeaderData(DetectEngineThreadCtx *det_ctx, const uint8_t flags,
const uint8_t flags, const DetectEngineTransforms *transforms, const DetectEngineTransforms *transforms, Flow *_f, const struct MpmListIdDataArgs *cbdata,
Flow *_f, const struct MpmListIdDataArgs *cbdata, int list_id)
int list_id, bool first)
{ {
SCEnter(); SCEnter();
@ -814,7 +812,7 @@ static InspectionBuffer *GetHttp2HeaderData(DetectEngineThreadCtx *det_ctx,
InspectionBufferMultipleForListGet(det_ctx, list_id, cbdata->local_id); InspectionBufferMultipleForListGet(det_ctx, list_id, cbdata->local_id);
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
if (!first && buffer->inspect != NULL) if (buffer->initialized)
return buffer; return buffer;
uint32_t b_len = 0; uint32_t b_len = 0;
@ -845,8 +843,8 @@ static void PrefilterTxHttp2Header(DetectEngineThreadCtx *det_ctx, const void *p
// loop until we get a NULL // loop until we get a NULL
struct MpmListIdDataArgs cbdata = { local_id, txv }; struct MpmListIdDataArgs cbdata = { local_id, txv };
InspectionBuffer *buffer = GetHttp2HeaderData(det_ctx, flags, ctx->transforms, InspectionBuffer *buffer =
f, &cbdata, list_id, true); GetHttp2HeaderData(det_ctx, flags, ctx->transforms, f, &cbdata, list_id);
if (buffer == NULL) if (buffer == NULL)
break; break;
@ -890,8 +888,8 @@ static uint8_t DetectEngineInspectHttp2Header(DetectEngineCtx *de_ctx,
while (1) { while (1) {
struct MpmListIdDataArgs cbdata = { local_id, txv, }; struct MpmListIdDataArgs cbdata = { local_id, txv, };
InspectionBuffer *buffer = GetHttp2HeaderData(det_ctx, flags, InspectionBuffer *buffer =
transforms, f, &cbdata, engine->sm_list, false); GetHttp2HeaderData(det_ctx, flags, transforms, f, &cbdata, engine->sm_list);
if (buffer == NULL || buffer->inspect == NULL) if (buffer == NULL || buffer->inspect == NULL)
break; break;

Loading…
Cancel
Save