diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 9227943602b4..4139af55b1bb 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -57,9 +57,9 @@ typedef struct DetectFileextData_ { uint32_t flags; } DetectFileextData; -static int DetectFileextMatch (DetectEngineThreadCtx *, Flow *, - uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFileextSetup (DetectEngineCtx *, Signature *, const char *); +static int DetectFileextMatch( + DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); +static int DetectFileextSetup(DetectEngineCtx *, Signature *, const char *); #ifdef UNITTESTS static void DetectFileextRegisterTests(void); #endif @@ -76,16 +76,16 @@ void DetectFileextRegister(void) sigmatch_table[DETECT_FILEEXT].url = "/rules/file-keywords.html#fileext"; sigmatch_table[DETECT_FILEEXT].FileMatch = DetectFileextMatch; sigmatch_table[DETECT_FILEEXT].Setup = DetectFileextSetup; - sigmatch_table[DETECT_FILEEXT].Free = DetectFileextFree; + sigmatch_table[DETECT_FILEEXT].Free = DetectFileextFree; #ifdef UNITTESTS sigmatch_table[DETECT_FILEEXT].RegisterTests = DetectFileextRegisterTests; #endif - sigmatch_table[DETECT_FILEEXT].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION; + sigmatch_table[DETECT_FILEEXT].flags = SIGMATCH_QUOTES_OPTIONAL | SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_FILEEXT].alternative = DETECT_FILE_NAME; g_file_match_list_id = DetectBufferTypeRegister("files"); - SCLogDebug("registering fileext rule option"); + SCLogDebug("registering fileext rule option"); return; } @@ -103,8 +103,8 @@ void DetectFileextRegister(void) * \retval 0 no match * \retval 1 match */ -static int DetectFileextMatch (DetectEngineThreadCtx *det_ctx, - Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m) +static int DetectFileextMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, + const Signature *s, const SigMatchCtx *m) { SCEnter(); int ret = 0; @@ -121,8 +121,7 @@ static int DetectFileextMatch (DetectEngineThreadCtx *det_ctx, /* fileext->ext is already in lowercase, as SCMemcmpLowercase requires */ if (file->name[offset - 1] == '.' && - SCMemcmpLowercase(fileext->ext, file->name + offset, fileext->len) == 0) - { + SCMemcmpLowercase(fileext->ext, file->name + offset, fileext->len) == 0) { if (!(fileext->flags & DETECT_CONTENT_NEGATED)) { ret = 1; SCLogDebug("File ext found"); @@ -144,7 +143,7 @@ static int DetectFileextMatch (DetectEngineThreadCtx *det_ctx, * \retval pointer to DetectFileextData on success * \retval NULL on failure */ -static DetectFileextData *DetectFileextParse (DetectEngineCtx *de_ctx, const char *str, bool negate) +static DetectFileextData *DetectFileextParse(DetectEngineCtx *de_ctx, const char *str, bool negate) { DetectFileextData *fileext = NULL; @@ -189,7 +188,6 @@ static DetectFileextData *DetectFileextParse (DetectEngineCtx *de_ctx, const cha if (fileext != NULL) DetectFileextFree(de_ctx, fileext); return NULL; - } /** @@ -203,7 +201,7 @@ static DetectFileextData *DetectFileextParse (DetectEngineCtx *de_ctx, const cha * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) +static int DetectFileextSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectFileextData *fileext = DetectFileextParse(de_ctx, str, s->init_data->negated); if (fileext == NULL) @@ -220,7 +218,7 @@ static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char SigMatchAppendSMToList(s, sm, g_file_match_list_id); - s->file_flags |= (FILE_SIG_NEED_FILE|FILE_SIG_NEED_FILENAME); + s->file_flags |= (FILE_SIG_NEED_FILE | FILE_SIG_NEED_FILENAME); return 0; error: @@ -250,7 +248,7 @@ static void DetectFileextFree(DetectEngineCtx *de_ctx, void *ptr) /** * \test DetectFileextTestParse01 */ -static int DetectFileextTestParse01 (void) +static int DetectFileextTestParse01(void) { DetectFileextData *dfd = DetectFileextParse(NULL, "doc", false); FAIL_IF_NULL(dfd); @@ -262,7 +260,7 @@ static int DetectFileextTestParse01 (void) /** * \test DetectFileextTestParse02 */ -static int DetectFileextTestParse02 (void) +static int DetectFileextTestParse02(void) { DetectFileextData *dfd = DetectFileextParse(NULL, "tar.gz", false); FAIL_IF_NULL(dfd); @@ -276,7 +274,7 @@ static int DetectFileextTestParse02 (void) /** * \test DetectFileextTestParse03 */ -static int DetectFileextTestParse03 (void) +static int DetectFileextTestParse03(void) { DetectFileextData *dfd = DetectFileextParse(NULL, "pdf", false); FAIL_IF_NULL(dfd); diff --git a/src/detect-fileext.h b/src/detect-fileext.h index 23088666bd84..23419cf47b4e 100644 --- a/src/detect-fileext.h +++ b/src/detect-fileext.h @@ -25,6 +25,6 @@ #define __DETECT_FILEEXT_H__ /* prototypes */ -void DetectFileextRegister (void); +void DetectFileextRegister(void); #endif /* __DETECT_FILEEXT_H__ */ diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index 628aa842fd9c..92a661f3122f 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -91,9 +91,9 @@ typedef struct DetectFilemagicData { uint32_t flags; } DetectFilemagicData; -static int DetectFilemagicMatch (DetectEngineThreadCtx *, Flow *, - uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, const char *); +static int DetectFilemagicMatch( + DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); +static int DetectFilemagicSetup(DetectEngineCtx *, Signature *, const char *); #ifdef UNITTESTS static void DetectFilemagicRegisterTests(void); #endif @@ -121,7 +121,7 @@ void DetectFilemagicRegister(void) sigmatch_table[DETECT_FILEMAGIC].url = "/rules/file-keywords.html#filemagic"; sigmatch_table[DETECT_FILEMAGIC].FileMatch = DetectFilemagicMatch; sigmatch_table[DETECT_FILEMAGIC].Setup = DetectFilemagicSetup; - sigmatch_table[DETECT_FILEMAGIC].Free = DetectFilemagicFree; + sigmatch_table[DETECT_FILEMAGIC].Free = DetectFilemagicFree; #ifdef UNITTESTS sigmatch_table[DETECT_FILEMAGIC].RegisterTests = DetectFilemagicRegisterTests; #endif @@ -208,15 +208,16 @@ int FilemagicThreadLookup(magic_t *ctx, File *file) * \retval 0 no match * \retval 1 match */ -static int DetectFilemagicMatch (DetectEngineThreadCtx *det_ctx, - Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m) +static int DetectFilemagicMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, + const Signature *s, const SigMatchCtx *m) { SCEnter(); int ret = 0; DetectFilemagicData *filemagic = (DetectFilemagicData *)m; DetectFilemagicThreadData *tfilemagic = - (DetectFilemagicThreadData *)DetectThreadCtxGetKeywordThreadCtx(det_ctx, g_magic_thread_ctx_id); + (DetectFilemagicThreadData *)DetectThreadCtxGetKeywordThreadCtx( + det_ctx, g_magic_thread_ctx_id); if (tfilemagic == NULL) { SCReturnInt(0); } @@ -231,8 +232,7 @@ static int DetectFilemagicMatch (DetectEngineThreadCtx *det_ctx, /* we include the \0 in the inspection, so patterns can match on the * end of the string. */ if (BoyerMooreNocase(filemagic->name, filemagic->len, (uint8_t *)file->magic, - strlen(file->magic) + 1, filemagic->bm_ctx) != NULL) - { + strlen(file->magic) + 1, filemagic->bm_ctx) != NULL) { #ifdef DEBUG if (SCLogDebugEnabled()) { char *name = SCMalloc(filemagic->len + 1); @@ -266,7 +266,8 @@ static int DetectFilemagicMatch (DetectEngineThreadCtx *det_ctx, * \retval filemagic pointer to DetectFilemagicData on success * \retval NULL on failure */ -static DetectFilemagicData *DetectFilemagicParse (DetectEngineCtx *de_ctx, const char *str, bool negate) +static DetectFilemagicData *DetectFilemagicParse( + DetectEngineCtx *de_ctx, const char *str, bool negate) { DetectFilemagicData *filemagic = NULL; @@ -277,7 +278,7 @@ static DetectFilemagicData *DetectFilemagicParse (DetectEngineCtx *de_ctx, const memset(filemagic, 0x00, sizeof(DetectFilemagicData)); - if (DetectContentDataParse ("filemagic", str, &filemagic->name, &filemagic->len) == -1) { + if (DetectContentDataParse("filemagic", str, &filemagic->name, &filemagic->len) == -1) { goto error; } @@ -381,7 +382,7 @@ static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, const ch SigMatchAppendSMToList(s, sm, g_file_match_list_id); - s->file_flags |= (FILE_SIG_NEED_FILE|FILE_SIG_NEED_MAGIC); + s->file_flags |= (FILE_SIG_NEED_FILE | FILE_SIG_NEED_MAGIC); return 0; error: @@ -582,7 +583,7 @@ static int PrefilterMpmFilemagicRegister(DetectEngineCtx *de_ctx, SigGroupHead * /** * \test DetectFilemagicTestParse01 */ -static int DetectFilemagicTestParse01 (void) +static int DetectFilemagicTestParse01(void) { DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "secret.pdf", false); FAIL_IF_NULL(dnd); @@ -593,7 +594,7 @@ static int DetectFilemagicTestParse01 (void) /** * \test DetectFilemagicTestParse02 */ -static int DetectFilemagicTestParse02 (void) +static int DetectFilemagicTestParse02(void) { DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "backup.tar.gz", false); FAIL_IF_NULL(dnd); @@ -606,7 +607,7 @@ static int DetectFilemagicTestParse02 (void) /** * \test DetectFilemagicTestParse03 */ -static int DetectFilemagicTestParse03 (void) +static int DetectFilemagicTestParse03(void) { DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "cmd.exe", false); FAIL_IF_NULL(dnd); @@ -625,6 +626,5 @@ void DetectFilemagicRegisterTests(void) UtRegisterTest("DetectFilemagicTestParse02", DetectFilemagicTestParse02); UtRegisterTest("DetectFilemagicTestParse03", DetectFilemagicTestParse03); } -#endif /* UNITTESTS */ +#endif /* UNITTESTS */ #endif /* HAVE_MAGIC */ - diff --git a/src/detect-filename.c b/src/detect-filename.c index 548e4aaee97d..710e0333d734 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -63,8 +63,8 @@ typedef struct DetectFilenameData { uint32_t flags; } DetectFilenameData; -static int DetectFilenameMatch (DetectEngineThreadCtx *, Flow *, - uint8_t, File *, const Signature *, const SigMatchCtx *); +static int DetectFilenameMatch( + DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); static int DetectFilenameSetup (DetectEngineCtx *, Signature *, const char *); static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str); #ifdef UNITTESTS @@ -90,7 +90,7 @@ void DetectFilenameRegister(void) sigmatch_table[DETECT_FILENAME].url = "/rules/file-keywords.html#filename"; sigmatch_table[DETECT_FILENAME].FileMatch = DetectFilenameMatch; sigmatch_table[DETECT_FILENAME].Setup = DetectFilenameSetup; - sigmatch_table[DETECT_FILENAME].Free = DetectFilenameFree; + sigmatch_table[DETECT_FILENAME].Free = DetectFilenameFree; #ifdef UNITTESTS sigmatch_table[DETECT_FILENAME].RegisterTests = DetectFilenameRegisterTests; #endif @@ -159,8 +159,8 @@ void DetectFilenameRegister(void) * \retval 0 no match * \retval 1 match */ -static int DetectFilenameMatch (DetectEngineThreadCtx *det_ctx, - Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m) +static int DetectFilenameMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, + const Signature *s, const SigMatchCtx *m) { SCEnter(); int ret = 0; @@ -170,9 +170,8 @@ static int DetectFilenameMatch (DetectEngineThreadCtx *det_ctx, if (file->name == NULL) SCReturnInt(0); - if (BoyerMooreNocase(filename->name, filename->len, file->name, - file->name_len, filename->bm_ctx) != NULL) - { + if (BoyerMooreNocase(filename->name, filename->len, file->name, file->name_len, + filename->bm_ctx) != NULL) { #ifdef DEBUG if (SCLogDebugEnabled()) { char *name = SCMalloc(filename->len + 1); @@ -207,13 +206,14 @@ static int DetectFilenameMatch (DetectEngineThreadCtx *det_ctx, * \retval filename pointer to DetectFilenameData on success * \retval NULL on failure */ -static DetectFilenameData *DetectFilenameParse (DetectEngineCtx *de_ctx, const char *str, bool negate) +static DetectFilenameData *DetectFilenameParse( + DetectEngineCtx *de_ctx, const char *str, bool negate) { DetectFilenameData *filename = SCCalloc(1, sizeof(DetectFilenameData)); if (unlikely(filename == NULL)) return NULL; - if (DetectContentDataParse ("filename", str, &filename->name, &filename->len) == -1) { + if (DetectContentDataParse("filename", str, &filename->name, &filename->len) == -1) { goto error; } @@ -281,7 +281,7 @@ static int DetectFilenameSetup (DetectEngineCtx *de_ctx, Signature *s, const cha SigMatchAppendSMToList(s, sm, g_file_match_list_id); - s->file_flags |= (FILE_SIG_NEED_FILE|FILE_SIG_NEED_FILENAME); + s->file_flags |= (FILE_SIG_NEED_FILE | FILE_SIG_NEED_FILENAME); return 0; error: @@ -480,7 +480,7 @@ static int DetectFilenameSignatureParseTest01(void) /** * \test DetectFilenameTestParse01 */ -static int DetectFilenameTestParse01 (void) +static int DetectFilenameTestParse01(void) { DetectFilenameData *dnd = DetectFilenameParse(NULL, "secret.pdf", false); FAIL_IF_NULL(dnd); @@ -491,7 +491,7 @@ static int DetectFilenameTestParse01 (void) /** * \test DetectFilenameTestParse02 */ -static int DetectFilenameTestParse02 (void) +static int DetectFilenameTestParse02(void) { DetectFilenameData *dnd = DetectFilenameParse(NULL, "backup.tar.gz", false); FAIL_IF_NULL(dnd); @@ -504,7 +504,7 @@ static int DetectFilenameTestParse02 (void) /** * \test DetectFilenameTestParse03 */ -static int DetectFilenameTestParse03 (void) +static int DetectFilenameTestParse03(void) { DetectFilenameData *dnd = DetectFilenameParse(NULL, "cmd.exe", false); FAIL_IF_NULL(dnd); diff --git a/src/detect-tls.h b/src/detect-tls.h index 71652eb99dec..d40f26a4b545 100644 --- a/src/detect-tls.h +++ b/src/detect-tls.h @@ -38,8 +38,8 @@ typedef struct DetectTlsData_ { uint16_t ver; /** tls version to match */ uint32_t flags; /** flags containing match variant (Negation for example) */ char * subject; /** tls certificate subject substring to match */ - char * issuerdn; /** tls certificate issuerDN substring to match */ - char * fingerprint; /** tls fingerprint substring to match */ + char *issuerdn; /** tls certificate issuerDN substring to match */ + char *fingerprint; /** tls fingerprint substring to match */ } DetectTlsData; /* prototypes */