Skip to content

Commit

Permalink
detect/file: use util to turn keyword to nocase
Browse files Browse the repository at this point in the history
This changes the way the pattern is stored by making it lowercase.
  • Loading branch information
victorjulien committed Aug 7, 2023
1 parent ef936ac commit c5d83d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
7 changes: 1 addition & 6 deletions src/detect-filemagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,8 @@ static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
return -1;

DetectContentData *cd = (DetectContentData *)sm->ctx;
cd->flags |= DETECT_CONTENT_NOCASE;
/* Recreate the context with nocase chars */
SpmDestroyCtx(cd->spm_ctx);
cd->spm_ctx = SpmInitCtx(cd->content, cd->content_len, 1, de_ctx->spm_global_thread_ctx);
if (cd->spm_ctx == NULL) {
if (DetectContentConvertToNocase(de_ctx, cd) != 0)
return -1;
}
if (DetectEngineContentModifierBufferSetup(
de_ctx, s, NULL, DETECT_FILE_MAGIC, g_file_magic_buffer_id, s->alproto) < 0)
return -1;
Expand Down
14 changes: 2 additions & 12 deletions src/detect-filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,9 @@ static int DetectFileextSetup(DetectEngineCtx *de_ctx, Signature *s, const char
return -1;

DetectContentData *cd = (DetectContentData *)sm->ctx;
cd->flags |= DETECT_CONTENT_NOCASE;
cd->flags |= DETECT_CONTENT_ENDS_WITH;
/* Recreate the context with nocase chars */
SpmDestroyCtx(cd->spm_ctx);
cd->spm_ctx = SpmInitCtx(cd->content, cd->content_len, 1, de_ctx->spm_global_thread_ctx);
if (cd->spm_ctx == NULL) {
if (DetectContentConvertToNocase(de_ctx, cd) != 0)
return -1;
}
if (DetectEngineContentModifierBufferSetup(
de_ctx, s, NULL, DETECT_FILE_NAME, g_file_name_buffer_id, s->alproto) < 0)
return -1;
Expand Down Expand Up @@ -191,13 +186,8 @@ static int DetectFilenameSetup (DetectEngineCtx *de_ctx, Signature *s, const cha
return -1;

DetectContentData *cd = (DetectContentData *)sm->ctx;
cd->flags |= DETECT_CONTENT_NOCASE;
/* Recreate the context with nocase chars */
SpmDestroyCtx(cd->spm_ctx);
cd->spm_ctx = SpmInitCtx(cd->content, cd->content_len, 1, de_ctx->spm_global_thread_ctx);
if (cd->spm_ctx == NULL) {
if (DetectContentConvertToNocase(de_ctx, cd) != 0)
return -1;
}
if (DetectEngineContentModifierBufferSetup(
de_ctx, s, NULL, DETECT_FILE_NAME, g_file_name_buffer_id, s->alproto) < 0)
return -1;
Expand Down

0 comments on commit c5d83d0

Please sign in to comment.