From: Victor Julien Date: Thu, 9 Aug 2018 09:45:18 +0000 (+0200) Subject: detect/dnp3: cleanup list and proto registration X-Git-Tag: suricata-4.1.0-rc2~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbd5ca3f6942dafb8dcd23a1878e2b150ac8451c;p=thirdparty%2Fsuricata.git detect/dnp3: cleanup list and proto registration --- diff --git a/src/detect-dnp3.c b/src/detect-dnp3.c index ebb3e13609..85f8e918c9 100644 --- a/src/detect-dnp3.c +++ b/src/detect-dnp3.c @@ -211,6 +211,9 @@ static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, const char SigMatch *sm = NULL; uint8_t function_code; + if (DetectSignatureSetAppProto(s, ALPROTO_DNP3) != 0) + return -1; + if (!DetectDNP3FuncParseFunctionCode(str, &function_code)) { SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid argument \"%s\" supplied to dnp3_func keyword.", str); @@ -229,8 +232,6 @@ static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, const char } sm->type = DETECT_AL_DNP3FUNC; sm->ctx = (void *)dnp3; - s->alproto = ALPROTO_DNP3; - s->flags |= SIG_FLAG_STATE_MATCH; SigMatchAppendSMToList(s, sm, g_dnp3_match_buffer_id); @@ -298,6 +299,9 @@ static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, const char SigMatch *sm = NULL; uint16_t flags; + if (DetectSignatureSetAppProto(s, ALPROTO_DNP3) != 0) + return -1; + if (!DetectDNP3IndParse(str, &flags)) { SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid argument \"%s\" supplied to dnp3.ind keyword.", str); @@ -316,9 +320,6 @@ static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, const char } sm->type = DETECT_AL_DNP3IND; sm->ctx = (void *)detect; - s->alproto = ALPROTO_DNP3; - s->flags |= SIG_FLAG_STATE_MATCH; - SigMatchAppendSMToList(s, sm, g_dnp3_match_buffer_id); SCReturnInt(0); @@ -373,6 +374,9 @@ static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, const char DetectDNP3 *detect = NULL; SigMatch *sm = NULL; + if (DetectSignatureSetAppProto(s, ALPROTO_DNP3) != 0) + return -1; + if (!DetectDNP3ObjParse(str, &group, &variation)) { goto fail; } @@ -390,8 +394,6 @@ static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, const char } sm->type = DETECT_AL_DNP3OBJ; sm->ctx = (void *)detect; - s->alproto = ALPROTO_DNP3; - s->flags |= SIG_FLAG_STATE_MATCH; SigMatchAppendSMToList(s, sm, g_dnp3_match_buffer_id); SCReturnInt(1); @@ -528,8 +530,10 @@ static void DetectDNP3ObjRegister(void) static int DetectDNP3DataSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); - s->init_data->list = g_dnp3_data_buffer_id; - s->alproto = ALPROTO_DNP3; + if (DetectSignatureSetAppProto(s, ALPROTO_DNP3) != 0) + return -1; + + DetectBufferSetActiveList(s, g_dnp3_data_buffer_id); SCReturnInt(0); }