detect/mqtt: update buffer initialization logic

pull/8482/head
Victor Julien 4 years ago
parent 83e97a9283
commit 6f1574276f

@ -65,8 +65,8 @@ struct MQTTSubscribeTopicGetDataArgs {
}; };
static InspectionBuffer *MQTTSubscribeTopicGetData(DetectEngineThreadCtx *det_ctx, static InspectionBuffer *MQTTSubscribeTopicGetData(DetectEngineThreadCtx *det_ctx,
const DetectEngineTransforms *transforms, const DetectEngineTransforms *transforms, Flow *f,
Flow *f, struct MQTTSubscribeTopicGetDataArgs *cbdata, int list_id, bool first) struct MQTTSubscribeTopicGetDataArgs *cbdata, int list_id)
{ {
SCEnter(); SCEnter();
@ -74,7 +74,7 @@ static InspectionBuffer *MQTTSubscribeTopicGetData(DetectEngineThreadCtx *det_ct
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;
const uint8_t *data; const uint8_t *data;
@ -101,8 +101,8 @@ static uint8_t DetectEngineInspectMQTTSubscribeTopic(DetectEngineCtx *de_ctx,
while ((subscribe_topic_match_limit == 0) || local_id < subscribe_topic_match_limit) { while ((subscribe_topic_match_limit == 0) || local_id < subscribe_topic_match_limit) {
struct MQTTSubscribeTopicGetDataArgs cbdata = { local_id, txv, }; struct MQTTSubscribeTopicGetDataArgs cbdata = { local_id, txv, };
InspectionBuffer *buffer = MQTTSubscribeTopicGetData(det_ctx, InspectionBuffer *buffer =
transforms, f, &cbdata, engine->sm_list, false); MQTTSubscribeTopicGetData(det_ctx, transforms, f, &cbdata, engine->sm_list);
if (buffer == NULL || buffer->inspect == NULL) if (buffer == NULL || buffer->inspect == NULL)
break; break;
@ -151,8 +151,8 @@ static void PrefilterTxMQTTSubscribeTopic(DetectEngineThreadCtx *det_ctx, const
uint32_t local_id = 0; uint32_t local_id = 0;
while ((subscribe_topic_match_limit == 0) || local_id < subscribe_topic_match_limit) { while ((subscribe_topic_match_limit == 0) || local_id < subscribe_topic_match_limit) {
struct MQTTSubscribeTopicGetDataArgs cbdata = { local_id, txv }; struct MQTTSubscribeTopicGetDataArgs cbdata = { local_id, txv };
InspectionBuffer *buffer = MQTTSubscribeTopicGetData(det_ctx, ctx->transforms, InspectionBuffer *buffer =
f, &cbdata, list_id, true); MQTTSubscribeTopicGetData(det_ctx, ctx->transforms, f, &cbdata, list_id);
if (buffer == NULL) if (buffer == NULL)
break; break;

@ -65,8 +65,8 @@ struct MQTTUnsubscribeTopicGetDataArgs {
}; };
static InspectionBuffer *MQTTUnsubscribeTopicGetData(DetectEngineThreadCtx *det_ctx, static InspectionBuffer *MQTTUnsubscribeTopicGetData(DetectEngineThreadCtx *det_ctx,
const DetectEngineTransforms *transforms, const DetectEngineTransforms *transforms, Flow *f,
Flow *f, struct MQTTUnsubscribeTopicGetDataArgs *cbdata, int list_id, bool first) struct MQTTUnsubscribeTopicGetDataArgs *cbdata, int list_id)
{ {
SCEnter(); SCEnter();
@ -74,7 +74,7 @@ static InspectionBuffer *MQTTUnsubscribeTopicGetData(DetectEngineThreadCtx *det_
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;
const uint8_t *data; const uint8_t *data;
@ -101,8 +101,8 @@ static uint8_t DetectEngineInspectMQTTUnsubscribeTopic(DetectEngineCtx *de_ctx,
while ((unsubscribe_topic_match_limit == 0) || local_id < unsubscribe_topic_match_limit) { while ((unsubscribe_topic_match_limit == 0) || local_id < unsubscribe_topic_match_limit) {
struct MQTTUnsubscribeTopicGetDataArgs cbdata = { local_id, txv, }; struct MQTTUnsubscribeTopicGetDataArgs cbdata = { local_id, txv, };
InspectionBuffer *buffer = MQTTUnsubscribeTopicGetData(det_ctx, InspectionBuffer *buffer =
transforms, f, &cbdata, engine->sm_list, false); MQTTUnsubscribeTopicGetData(det_ctx, transforms, f, &cbdata, engine->sm_list);
if (buffer == NULL || buffer->inspect == NULL) if (buffer == NULL || buffer->inspect == NULL)
break; break;
@ -151,8 +151,8 @@ static void PrefilterTxMQTTUnsubscribeTopic(DetectEngineThreadCtx *det_ctx, cons
uint32_t local_id = 0; uint32_t local_id = 0;
while ((unsubscribe_topic_match_limit == 0) || local_id < unsubscribe_topic_match_limit) { while ((unsubscribe_topic_match_limit == 0) || local_id < unsubscribe_topic_match_limit) {
struct MQTTUnsubscribeTopicGetDataArgs cbdata = { local_id, txv }; struct MQTTUnsubscribeTopicGetDataArgs cbdata = { local_id, txv };
InspectionBuffer *buffer = MQTTUnsubscribeTopicGetData(det_ctx, ctx->transforms, InspectionBuffer *buffer =
f, &cbdata, list_id, true); MQTTUnsubscribeTopicGetData(det_ctx, ctx->transforms, f, &cbdata, list_id);
if (buffer == NULL) if (buffer == NULL)
break; break;

Loading…
Cancel
Save