detect/magic: fix crash on rule reloading

This changseset fixes a bug causing a segmentation fault.
When rules are reloaded and a rule using libmagic matches, suricata
crashes due to an improper reinitialization of the thread contexts.

Bug: #3726
pull/5533/head
Angelo Mirabella 5 years ago committed by Victor Julien
parent ea15282f47
commit c72069c3b2

@ -361,13 +361,10 @@ static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
if (filemagic == NULL)
return -1;
if (g_magic_thread_ctx_id == -1) {
g_magic_thread_ctx_id = DetectRegisterThreadCtxFuncs(de_ctx, "filemagic",
DetectFilemagicThreadInit, (void *)filemagic,
DetectFilemagicThreadFree, 1);
if (g_magic_thread_ctx_id == -1)
goto error;
}
g_magic_thread_ctx_id = DetectRegisterThreadCtxFuncs(de_ctx, "filemagic",
DetectFilemagicThreadInit, (void *)filemagic, DetectFilemagicThreadFree, 1);
if (g_magic_thread_ctx_id == -1)
goto error;
/* Okay so far so good, lets get this into a SigMatch
* and put it in the Signature. */

Loading…
Cancel
Save