[openssl] master update

Richard Levitte levitte at openssl.org
Wed May 6 18:17:11 UTC 2020


The branch master has been updated
       via  4975e8b4d2cfab923d522840533334a1bbd754b8 (commit)
      from  edbb56ee4fafc07eb77747ad25278a04b89adc09 (commit)


- Log -----------------------------------------------------------------
commit 4975e8b4d2cfab923d522840533334a1bbd754b8
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue May 5 16:53:43 2020 +0200

    Configure: avoid perl regexp bugs
    
    It seems that in older perl versions '(?P' doesn't interact very well
    with '(?|' or '(?:'.
    
    Since we make extensive use of '(?P' in build.info parsing, we avoid
    combining that with '(?|' and '(?:' when parsing build.info variables,
    and end up parsing variable modifier twice (first generally, and then
    parse that result into the modifier components).
    
    Fixes #11694
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/11737)

-----------------------------------------------------------------------

Summary of changes:
 Configure | 58 ++++++++++++++++++++++++++--------------------------------
 1 file changed, 26 insertions(+), 32 deletions(-)

diff --git a/Configure b/Configure
index 4a23d26a9b..7738073455 100755
--- a/Configure
+++ b/Configure
@@ -1831,23 +1831,13 @@ if ($builder eq "unified") {
         my $variable_name_re = qr/(?P<VARIABLE>[[:alpha:]][[:alnum:]_]*)/;
         # Value modifier syntaxes
         my $variable_subst_re = qr/\/(?P<RE>(?:\\\/|.)*?)\/(?P<SUBST>.*?)/;
-        # Put it all together
-        my $variable_re = qr/\$
-                             (?|
-                                 # Simple case, just the name
-                                 ${variable_name_re}
-                             |
-                                 # Expressive case, with braces and possible
-                                 # modifier expressions
-                                 \{
-                                 ${variable_name_re}
-                                 (?:
-                                     # Pile on modifier expressions,
-                                     # separated by |
-                                     ${variable_subst_re}
-                                 )
-                                 \}
-                             )/x;
+        # Variable reference
+        my $variable_simple_re = qr/(?<!\\)\$${variable_name_re}/;
+        my $variable_w_mod_re =
+            qr/(?<!\\)\$\{${variable_name_re}(?P<MOD>(?:\\\/|.)*?)\}/;
+        # Tie it all together
+        my $variable_re = qr/${variable_simple_re}|${variable_w_mod_re}/;
+
         my $expand_variables = sub {
             my $value = '';
             my $value_rest = shift;
@@ -1856,25 +1846,29 @@ if ($builder eq "unified") {
                 print STDERR
                     "DEBUG[\$expand_variables] Parsed '$value_rest' ...\n"
             }
-            while ($value_rest =~ /(?<!\\)${variable_re}/) {
-                $value_rest = $';
-                $value .= $`;
 
+            while ($value_rest =~ /${variable_re}/) {
+                # We must save important regexp values, because the next
+                # regexp clears them
+                my $mod = $+{MOD};
                 my $variable_value = $variables{$+{VARIABLE}};
 
+                $value_rest = $';
+                $value .= $`;
+
                 # Process modifier expressions, if present
-                if (defined $+{RE}) {
-                    # We must save important %+ values, because the s///
-                    # below clears them
-                    my $re = $+{RE};
-                    my $subst = $+{SUBST};
-
-                    $variable_value =~ s/\Q$re\E/$subst/g;
-
-                    if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
-                        print STDERR
-                            "DEBUG[\$expand_variables] ... and substituted ",
-                            "'$re' with '$subst'\n";
+                if (defined $mod) {
+                    if ($mod =~ /^${variable_subst_re}$/) {
+                        my $re = $+{RE};
+                        my $subst = $+{SUBST};
+
+                        $variable_value =~ s/\Q$re\E/$subst/g;
+
+                        if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
+                            print STDERR
+                                "DEBUG[\$expand_variables] ... and substituted ",
+                                "'$re' with '$subst'\n";
+                        }
                     }
                 }
 


More information about the openssl-commits mailing list