detect/file: minor cleanups

pull/7654/head
Victor Julien 3 years ago
parent af145ad125
commit ad3e68f378

@ -206,16 +206,13 @@ error:
*/
static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
DetectFileextData *fileext= NULL;
SigMatch *sm = NULL;
fileext = DetectFileextParse(de_ctx, str, s->init_data->negated);
DetectFileextData *fileext = DetectFileextParse(de_ctx, str, s->init_data->negated);
if (fileext == NULL)
goto error;
return -1;
/* Okay so far so good, lets get this into a SigMatch
* and put it in the Signature. */
sm = SigMatchAlloc();
SigMatch *sm = SigMatchAlloc();
if (sm == NULL)
goto error;
@ -228,12 +225,10 @@ static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char
return 0;
error:
if (fileext != NULL)
DetectFileextFree(de_ctx, fileext);
if (sm != NULL)
SCFree(sm);
return -1;
}
/**

@ -230,14 +230,9 @@ static int DetectFilenameMatch (DetectEngineThreadCtx *det_ctx,
*/
static DetectFilenameData *DetectFilenameParse (DetectEngineCtx *de_ctx, const char *str, bool negate)
{
DetectFilenameData *filename = NULL;
/* We have a correct filename option */
filename = SCMalloc(sizeof(DetectFilenameData));
DetectFilenameData *filename = SCCalloc(1, sizeof(DetectFilenameData));
if (unlikely(filename == NULL))
goto error;
memset(filename, 0x00, sizeof(DetectFilenameData));
return NULL;
if (DetectContentDataParse ("filename", str, &filename->name, &filename->len) == -1) {
goto error;
@ -272,7 +267,6 @@ static DetectFilenameData *DetectFilenameParse (DetectEngineCtx *de_ctx, const c
return filename;
error:
if (filename != NULL)
DetectFilenameFree(de_ctx, filename);
return NULL;
}

Loading…
Cancel
Save