[gnome-session/benzea/subpattern-nocapture] util: Disable capturing of subpatterns




commit e918d4c5b43735878a3dea2081a108c8bb30da8d
Author: Benjamin Berg <bberg redhat com>
Date:   Sun Jan 10 19:26:07 2021 +0100

    util: Disable capturing of subpatterns
    
    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

 gnome-session/gsm-util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gnome-session/gsm-util.c b/gnome-session/gsm-util.c
index 18a94700d..75a5e7ff3 100644
--- a/gnome-session/gsm-util.c
+++ b/gnome-session/gsm-util.c
@@ -550,7 +550,7 @@ gsm_util_export_activation_environment (GError     **error)
                 return FALSE;
         }
 
-        value_regex = g_regex_new ("^([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
+        value_regex = g_regex_new ("^(?:[[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
 
         if (value_regex == NULL) {
                 return FALSE;
@@ -633,7 +633,7 @@ gsm_util_export_user_environment (GError     **error)
                 return FALSE;
         }
 
-        regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, 
error);
+        regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=(?:[[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, 
error);
 
         if (regex == NULL) {
                 return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]