diff options
author | Dario Lombardo <lomato@gmail.com> | 2019-04-06 00:29:51 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2019-04-12 09:23:00 +0000 |
commit | c442ee056bc46bcda59e473c00d5741ea90a1453 (patch) | |
tree | c6c9d060e1741142dcee41bef8ade81289c9c66f /extcap_parser.c | |
parent | c1dcf8c3faa9c3646a78bb79be7f66ba9f78192b (diff) |
extcap_parser: remove G_REGEX_RAW from line parsing.
Check for utf8 valid line instead. Add a testcase that shows
how the former code was buggy on special characters extcap sentences.
Bug: 15668
Change-Id: Ic045c4791388af98705916e6ea84be8fc9b3c5b8
Reviewed-on: https://code.wireshark.org/review/32754
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'extcap_parser.c')
-rw-r--r-- | extcap_parser.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/extcap_parser.c b/extcap_parser.c index e1d4c5d8f4..62a5fc5aec 100644 --- a/extcap_parser.c +++ b/extcap_parser.c @@ -86,7 +86,9 @@ gdouble extcap_complex_get_double(extcap_complex *comp) { } static gboolean matches_regex(const char *pattern, const char *subject) { - return g_regex_match_simple(pattern, subject, (GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_RAW), (GRegexMatchFlags)0); + if (!g_utf8_validate(subject, -1, NULL)) + return FALSE; + return g_regex_match_simple(pattern, subject, (GRegexCompileFlags) (G_REGEX_CASELESS), (GRegexMatchFlags)0); } gboolean extcap_complex_get_bool(extcap_complex *comp) { @@ -111,13 +113,16 @@ static extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) { gchar *param_value = NULL; guint param_type = EXTCAP_PARAM_UNKNOWN; + if (!g_utf8_validate(s, -1, NULL)) + return FALSE; + extcap_token_sentence *rs = g_new0(extcap_token_sentence, 1); rs->sentence = NULL; /* Regex for catching just the allowed values for sentences */ if ((regex = g_regex_new("^[\\t| ]*(arg|value|interface|extcap|dlt|control)(?=[\\t| ]+\\{)", - (GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_RAW), + (GRegexCompileFlags) (G_REGEX_CASELESS), (GRegexMatchFlags) 0, NULL)) != NULL) { g_regex_match(regex, s, (GRegexMatchFlags) 0, &match_info); @@ -139,7 +144,7 @@ static extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) { * that regex patterns given to {validation=} are parsed correctly, * as long as }{ does not occur within the pattern */ regex = g_regex_new("\\{([a-zA-Z_-]*?)\\=(.*?)\\}(?=\\{|$|\\s)", - (GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_RAW), + (GRegexCompileFlags) (G_REGEX_CASELESS), (GRegexMatchFlags) 0, NULL); if (regex != NULL) { g_regex_match_full(regex, s, -1, 0, (GRegexMatchFlags) 0, &match_info, &error); |