diff --git a/src/detect-engine-proto.c b/src/detect-engine-proto.c index 95156de26b..24f0794c69 100644 --- a/src/detect-engine-proto.c +++ b/src/detect-engine-proto.c @@ -129,6 +129,7 @@ int DetectProtoContainsProto(const DetectProto *dp, int proto) #include "detect-engine.h" #include "detect-parse.h" #include "detect-engine-mpm.h" + /** * \brief this function is used to initialize the detection engine context and * setup the signature with passed values. @@ -138,32 +139,31 @@ static int DetectProtoInitTest(DetectEngineCtx **de_ctx, Signature **sig, { char fullstr[1024]; int result = 0; + static uint32_t test_sid = 1; - *de_ctx = NULL; *sig = NULL; - if (snprintf(fullstr, 1024, "alert %s any any -> any any (msg:\"DetectProto" - " test\"; sid:1;)", str) >= 1024) - { + if (snprintf(fullstr, 1024, + "alert %s any any -> any any (msg:\"DetectProto" + " test\"; sid:%u;)", + str, test_sid++) >= 1024) { goto end; } - *de_ctx = DetectEngineCtxInit(); if (*de_ctx == NULL) { - goto end; - } - - (*de_ctx)->flags |= DE_QUIET; + *de_ctx = DetectEngineCtxInit(); + if (*de_ctx == NULL) { + goto end; + } - (*de_ctx)->sig_list = SigInit(*de_ctx, fullstr); - if ((*de_ctx)->sig_list == NULL) { - goto end; + (*de_ctx)->flags |= DE_QUIET; } - *sig = (*de_ctx)->sig_list; - - if (DetectProtoParse(dp, str) < 0) + Signature *s = DetectEngineAppendSig(*de_ctx, fullstr); + if (s == NULL) { goto end; + } + *sig = s; result = 1;