Skip to content

Commit

Permalink
memory: Make regex patterns raw
Browse files Browse the repository at this point in the history
According to the docs of `g_regex_new`: "Usually strings must be valid
UTF-8 strings, using this flag they are considered as a raw sequence
of bytes."

The "strings" this refers to are the haystacks we then pass to
`g_regex_match_full` when searching.

Without the flag, memory search with regex patterns can get
interrupted before the range is over, when "invalid" bytes are
encountered, resulting in false negatives.
  • Loading branch information
mrmacete committed Oct 8, 2024
1 parent 76093ff commit 3ee1101
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gum/gummemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ gum_match_pattern_new_from_regex (const gchar * regex_str)
GumMatchPattern * pattern;
GRegex * regex;

regex = g_regex_new (regex_str, G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY,
regex = g_regex_new (regex_str, G_REGEX_OPTIMIZE | G_REGEX_RAW, G_REGEX_MATCH_NOTEMPTY,
NULL);
if (regex == NULL)
return NULL;
Expand Down

0 comments on commit 3ee1101

Please sign in to comment.