Skip to content

Commit

Permalink
util: Disable capturing of subpatterns
Browse files Browse the repository at this point in the history
It seems that the pattern we use will create a subpattern match for
every character of the value. This appears to then result in a stack
overflow when matching very long values.

It might be an idea to limit the overall length of an environment
variable that is uploaded. But, this should fix the issue of crashes.

Fixes: #42
  • Loading branch information
Benjamin Berg committed Jan 14, 2021
1 parent 87d92fe commit 3b57d11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gnome-session/gsm-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ gsm_util_export_activation_environment (GError **error)
return FALSE;
}

value_regex = g_regex_new ("^([ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
value_regex = g_regex_new ("^(?:[ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);

if (value_regex == NULL) {
return FALSE;
Expand Down Expand Up @@ -630,7 +630,7 @@ gsm_util_export_user_environment (GError **error)
return FALSE;
}

regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=([ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=(?:[ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);

if (regex == NULL) {
return FALSE;
Expand Down

0 comments on commit 3b57d11

Please sign in to comment.