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

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

Loading…
Cancel
Save