diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-04-12 19:57:05 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-04-12 19:57:05 +0000 |
commit | bb27e7b65ce5dddfbcc195ca657661d5cc662d88 (patch) | |
tree | 9f4f7b192a3f2e507fcac0d699277413c502e772 /t | |
parent | 3241943182ef83e0280bc5b8b03b564dc33de822 (diff) | |
download | perl-bb27e7b65ce5dddfbcc195ca657661d5cc662d88.tar.gz |
Integrate change #15879 from maint-5.6;
Win32::GetLongPathName() did not return valid results if there
were "." and ".." components in the path; also fix a potential
buffer overflow if the long path happens to be longer than
MAX_PATH (this can presumably happen if they use \\?\... style
paths); add a rather limited testsuite that exercises just the
edge cases
p4raw-link: @15879 on //depot/maint-5.6/perl: a15439704ef1059bf178ec4b1820fee7b2af7173
p4raw-id: //depot/perl@15880
p4raw-branched: from //depot/maint-5.6/perl@15877 'branch in'
t/win32/longpath.t
p4raw-integrated: from //depot/maint-5.6/perl@15877 'ignore' MANIFEST
(@12747..) 'merge in' t/harness (@11427..) win32/win32.c
(@13145..)
Diffstat (limited to 't')
-rw-r--r-- | t/harness | 1 | ||||
-rwxr-xr-x | t/win32/longpath.t | 52 |
2 files changed, 53 insertions, 0 deletions
@@ -57,6 +57,7 @@ if (@ARGV) { push @tests, <op/*.t>; push @tests, <uni/*.t>; push @tests, <lib/*.t>; + push @tests, <win32/*.t> if $^O eq 'MSWin32'; use File::Spec; my $updir = File::Spec->updir; my $mani = File::Spec->catfile(File::Spec->updir, "MANIFEST"); diff --git a/t/win32/longpath.t b/t/win32/longpath.t new file mode 100755 index 0000000000..d31a5b4dce --- /dev/null +++ b/t/win32/longpath.t @@ -0,0 +1,52 @@ +#!perl -w + +# tests for Win32::GetLongPathName() + +$^O =~ /^MSWin/ or print("1..0 # not win32\n" ), exit; + +my @paths = qw( + / + // + . + .. + c: + c:/ + c:./ + c:/. + c:/.. + c:./.. + //./ + //. + //.. + //./.. +); +push @paths, map { my $x = $_; $x =~ s,/,\\,g; $x } @paths; +push @paths, qw( + ../\ + c:.\\../\ + c:/\..// + c://.\/./\ + \\.\\../\ + //\..// + //.\/./\ +); + +my $drive = $ENV{SystemDrive}; +if ($drive) { + for (@paths) { + s/^c:/$drive/; + } + push @paths, $ENV{SystemRoot} if $ENV{SystemRoot}; +} +my %expect; +@expect{@paths} = map { my $x = $_; $x =~ s,(.[/\\])[/\\]+,$1,g; $x } @paths; + +print "1.." . @paths . "\n"; +my $i = 1; +for (@paths) { + my $got = Win32::GetLongPathName($_); + print "# '$_' => expect '$expect{$_}' => got '$got'\n"; + print "not " unless $expect{$_} eq $got; + print "ok $i\n"; + ++$i; +} |