In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/d1107db027ad52d2f50e348218625a8e122ca9eb?hp=abbca49b1b90bcf8e24c2ddb8423c503c144cbe2>

- Log -----------------------------------------------------------------
commit d1107db027ad52d2f50e348218625a8e122ca9eb
Author: Steve Hay <[email protected]>
Date:   Sun Sep 10 13:18:50 2017 +0100

    perldelta for 96c83ed78a, 2be4edede4 and 8586647e33

M       pod/perldelta.pod

commit 8586647e338e8eb42c00fe6f687105c9b8a36d44
Author: Tony Cook <[email protected]>
Date:   Thu Jul 27 10:12:02 2017 +1000

    (perl #131665) avoid a buffer overflow in a buffer we didn't need
    
    since Lookup() treats its argument as NUL or '=' terminated.
    
    Previously environment variable names longer than the size of the
    buffer would result in a buffer overflow.

M       t/win32/runenv.t
M       win32/perlhost.h

commit 2be4edede4ae226e2eebd4eff28cedd2041f300f
Author: Karl Williamson <[email protected]>
Date:   Fri Aug 25 11:33:58 2017 -0600

    PATCH: [perl #131598]
    
    The cause of this is that the vFAIL macro uses RExC_parse, and that
    variable has just been changed in preparation for code after the vFAIL.
    The solution is to not change RExC_parse until after the vFAIL.
    
    This is a case where the macro hides stuff that can bite you.

M       regcomp.c

commit 96c83ed78aeea1a0496dd2b2d935869a822dc8a5
Author: Karl Williamson <[email protected]>
Date:   Wed Jun 21 11:33:37 2017 -0600

    regcomp [perl #131582]

M       regcomp.c
-----------------------------------------------------------------------

Summary of changes:
 pod/perldelta.pod | 20 ++++++++++++++++++++
 regcomp.c         |  7 +++++--
 t/win32/runenv.t  | 21 ++++++++++++++++-----
 win32/perlhost.h  | 10 ++--------
 4 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 51a7a4d067..eb3d504414 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -35,6 +35,26 @@ L</Selected Bug Fixes> section.
 
 [ List each security issue as a =head2 entry ]
 
+=head2 [CVE-2017-12837] Heap buffer overflow in regular expression compiler
+
+Compiling certain regular expression patterns with the case-insensitive
+modifier could cause a heap buffer overflow and crash perl.  This has now been
+fixed.
+L<[perl #131582]|https://rt.perl.org/Public/Bug/Display.html?id=131582>
+
+=head2 [CVE-2017-12883] Buffer over-read in regular expression parser
+
+For certain types of syntax error in a regular expression pattern, the error
+message could either contain the contents of a random, possibly large, chunk of
+memory, or could crash perl.  This has now been fixed.
+L<[perl #131598]|https://rt.perl.org/Public/Bug/Display.html?id=131598>
+
+=head2 [CVE-2017-12814] C<$ENV{$key}> stack buffer overflow on Windows
+
+A possible stack buffer overflow in the C<%ENV> code on Windows has been fixed
+by removing the buffer completely since it was superfluous anyway.
+L<[perl #131665]|https://rt.perl.org/Public/Bug/Display.html?id=131665>
+
 =head1 Incompatible Changes
 
 XXX For a release on a stable branch, this section aspires to be:
diff --git a/regcomp.c b/regcomp.c
index 800b8cdc5e..c83315c73a 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12196,14 +12196,16 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
        }
         sv_catpv(substitute_parse, ")");
 
-        RExC_parse = RExC_start = RExC_adjusted_start = SvPV(substitute_parse,
-                                                             len);
+        len = SvCUR(substitute_parse);
 
        /* Don't allow empty number */
        if (len < (STRLEN) 8) {
             RExC_parse = endbrace;
            vFAIL("Invalid hexadecimal number in \\N{U+...}");
        }
+
+        RExC_parse = RExC_start = RExC_adjusted_start
+                                              = SvPV_nolen(substitute_parse);
        RExC_end = RExC_parse + len;
 
         /* The values are Unicode, and therefore not subject to recoding, but
@@ -13318,6 +13320,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, 
U32 depth)
                             goto loopdone;
                         }
                         p = RExC_parse;
+                        RExC_parse = parse_start;
                         if (ender > 0xff) {
                             REQUIRE_UTF8(flagp);
                         }
diff --git a/t/win32/runenv.t b/t/win32/runenv.t
index 514eda0c20..4746afaa4a 100644
--- a/t/win32/runenv.t
+++ b/t/win32/runenv.t
@@ -14,10 +14,10 @@ BEGIN {
     require Win32;
     ($::os_id, $::os_major) = ( Win32::GetOSVersion() )[ 4, 1 ];
     if ($::os_id == 2 and $::os_major == 6) {    # Vista, Server 2008 (incl 
R2), 7
-       $::tests = 43;
+       $::tests = 45;
     }
     else {
-       $::tests = 40;
+       $::tests = 42;
     }
 
     require './test.pl';
@@ -70,11 +70,12 @@ sub runperl_and_capture {
 }
 
 sub try {
-  my ($env, $args, $stdout, $stderr) = @_;
+  my ($env, $args, $stdout, $stderr, $name) = @_;
   my ($actual_stdout, $actual_stderr) = runperl_and_capture($env, $args);
+  $name ||= "";
   local $::Level = $::Level + 1;
-  is $actual_stdout, $stdout;
-  is $actual_stderr, $stderr;
+  is $actual_stdout, $stdout, "$name - stdout";
+  is $actual_stderr, $stderr, "$name - stderr";
 }
 
 #  PERL5OPT    Command-line options (switches).  Switches in
@@ -196,6 +197,16 @@ try({PERL5LIB => "foo",
     '',
     '');
 
+{
+    # 131665
+    # crashes without the fix
+    my $longname = "X" x 2048;
+    try({ $longname => 1 },
+        [ '-e', '"print q/ok/"' ],
+        'ok', '',
+        'very long env var names' );
+}
+
 # Tests for S_incpush_use_sep():
 
 my @dump_inc = ('-e', '"print \"$_\n\" foreach @INC"');
diff --git a/win32/perlhost.h b/win32/perlhost.h
index 84b08c9b90..3260f62a02 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -2177,17 +2177,11 @@ compare(const void *arg1, const void *arg2)
 void
 CPerlHost::Add(LPCSTR lpStr)
 {
-    char szBuffer[1024];
     LPSTR *lpPtr;
-    int index, length = strlen(lpStr)+1;
-
-    for(index = 0; lpStr[index] != '\0' && lpStr[index] != '='; ++index)
-       szBuffer[index] = lpStr[index];
-
-    szBuffer[index] = '\0';
+    STRLEN length = strlen(lpStr)+1;
 
     // replacing ?
-    lpPtr = Lookup(szBuffer);
+    lpPtr = Lookup(lpStr);
     if (lpPtr != NULL) {
        // must allocate things via host memory allocation functions 
        // rather than perl's Renew() et al, as the perl interpreter

--
Perl5 Master Repository

Reply via email to