summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-07-27 10:12:02 +1000
committerSteve Hay <steve.m.hay@googlemail.com>2017-09-10 14:13:14 +0100
commit205f8363fb14aa2b2995fd16da66583bd6b47f4f (patch)
tree4b39c5e10a39194a0849ef789a9a15e06bebf91b /t
parent40b3cdad3649334585cee8f4630ec9a025e62be6 (diff)
downloadperl-205f8363fb14aa2b2995fd16da66583bd6b47f4f.tar.gz
(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. (cherry picked from commit 8586647e338e8eb42c00fe6f687105c9b8a36d44)
Diffstat (limited to 't')
-rw-r--r--t/win32/runenv.t21
1 files changed, 16 insertions, 5 deletions
diff --git a/t/win32/runenv.t b/t/win32/runenv.t
index 0e2b0ca015..ff755563f0 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"');