summaryrefslogtreecommitdiff
path: root/t/win32/runenv.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 12:49:04 +0100
commit8586647e338e8eb42c00fe6f687105c9b8a36d44 (patch)
tree1990b47fba528541d0bd68f478e2ccf1922d304b /t/win32/runenv.t
parent2be4edede4ae226e2eebd4eff28cedd2041f300f (diff)
downloadperl-8586647e338e8eb42c00fe6f687105c9b8a36d44.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.
Diffstat (limited to 't/win32/runenv.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 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"');