Skip to content

Commit

Permalink
should use magic match len (arkime#3061)
Browse files Browse the repository at this point in the history
  • Loading branch information
awick authored Dec 16, 2024
1 parent 3cd2f5f commit a85fe22
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions capture/parsers.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ LOCAL GHashTable *namedFuncsHash;
#define MAGIC_MATCH(offset, needle) memcmp(data+offset, needle, sizeof(needle)-1) == 0
#define MAGIC_MATCH_LEN(offset, needle) ((len > (int)sizeof(needle)-1+offset) && (memcmp(data+offset, needle, sizeof(needle)-1) == 0))

#define MAGIC_MEMSTR(offset, needle) arkime_memstr(data+offset, len-offset, needle, sizeof(needle)-1)
#define MAGIC_MEMSTR_LEN(offset, needle) ((len > (int)sizeof(needle)-1+offset) && (arkime_memstr(data+offset, len-offset, needle, sizeof(needle)-1)))

#define MAGIC_STRCASE(offset, needle) strncasecmp(data+offset, needle, sizeof(needle)-1) == 0
Expand All @@ -64,7 +63,7 @@ const char *arkime_parsers_magic_basic(ArkimeSession_t *session, int field, cons
if (MAGIC_MATCH(0, "\000\001\000\000\000")) {
return MAGIC_RESULT("application/x-font-ttf");
}
if (MAGIC_MATCH(0, "\000\000\002\000\001\000")) {
if (MAGIC_MATCH_LEN(0, "\000\000\002\000\001\000")) {
return MAGIC_RESULT("image/x-win-bitmap");
}
break;
Expand Down

0 comments on commit a85fe22

Please sign in to comment.