diff options
author | Richard Levitte <levitte@openssl.org> | 2021-06-07 14:10:17 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-06-08 21:15:00 +0200 |
commit | 1355659bb83388a6ad98c730f38e94ec4e414b6b (patch) | |
tree | fe330900f9c2fb3ff264a2d815ddcecca3cdbb6e /util | |
parent | 4bf696c1d05d19ad495995309981f91f265cdaf2 (diff) |
OpenSSL::Test.pm: Replace all uses of rel2abs() with abs_path()
rel2abs() doesn't clean the path well enough, which may lead to odd
results when calculating new paths. abs_path() works better for this
sort of thing.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15644)
Diffstat (limited to 'util')
-rw-r--r-- | util/perl/OpenSSL/Test.pm | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm index 6960514ac6..ee6962931b 100644 --- a/util/perl/OpenSSL/Test.pm +++ b/util/perl/OpenSSL/Test.pm @@ -65,8 +65,7 @@ C<$SRCTOP/test/recipes/99-foo_data/>. use File::Copy; use File::Spec::Functions qw/file_name_is_absolute curdir canonpath splitdir - catdir catfile splitpath catpath devnull abs2rel - rel2abs/; + catdir catfile splitpath catpath devnull abs2rel/; use File::Path 2.00 qw/rmtree mkpath/; use File::Basename; use Cwd qw/getcwd abs_path/; @@ -1117,8 +1116,8 @@ sub __data_dir { sub __cwd { my $dir = catdir(shift); my %opts = @_; - my $abscurdir = rel2abs(curdir()); - my $absdir = rel2abs($dir); + my $abscurdir = abs_path(curdir()); + my $absdir = abs_path($dir); my $reverse = abs2rel($abscurdir, $absdir); # PARANOIA: if we're not moving anywhere, we do nothing more @@ -1152,7 +1151,14 @@ sub __cwd { my @dirtags = sort keys %directories; foreach (@dirtags) { if (!file_name_is_absolute($directories{$_})) { - my $newpath = abs2rel(rel2abs($directories{$_}), rel2abs($dir)); + my $oldpath = abs_path($directories{$_}); + my $newbase = abs_path($dir); + my $newpath = abs2rel($oldpath, $newbase); + if ($debug) { + print STDERR "DEBUG: [dir $_] old path: $oldpath\n"; + print STDERR "DEBUG: [dir $_] new base: $newbase\n"; + print STDERR "DEBUG: [dir $_] resulting new path: $newpath\n"; + } $tmp_directories{$_} = $newpath; } } @@ -1162,7 +1168,14 @@ sub __cwd { # process can use their values properly as well foreach (@direnv) { if (!file_name_is_absolute($ENV{$_})) { - my $newpath = abs2rel(rel2abs($ENV{$_}), rel2abs($dir)); + my $oldpath = abs_path($ENV{$_}); + my $newbase = abs_path($dir); + my $newpath = abs2rel($oldpath, $newbase); + if ($debug) { + print STDERR "DEBUG: [env $_] old path: $oldpath\n"; + print STDERR "DEBUG: [env $_] new base: $newbase\n"; + print STDERR "DEBUG: [env $_] resulting new path: $newpath\n"; + } $tmp_ENV{$_} = $newpath; } } @@ -1182,16 +1195,18 @@ sub __cwd { if ($debug) { print STDERR "DEBUG: __cwd(), directories and files:\n"; - print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n"; - print STDERR " \$directories{SRCTEST} = \"$directories{SRCTEST}\"\n"; - print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n"; - print STDERR " \$directories{RESULTS} = \"$directories{RESULTS}\"\n"; - print STDERR " \$directories{BLDAPPS} = \"$directories{BLDAPPS}\"\n"; - print STDERR " \$directories{SRCAPPS} = \"$directories{SRCAPPS}\"\n"; - print STDERR " \$directories{SRCTOP} = \"$directories{SRCTOP}\"\n"; - print STDERR " \$directories{BLDTOP} = \"$directories{BLDTOP}\"\n"; + print STDERR " Moving from $abscurdir\n"; + print STDERR " Moving to $absdir\n"; + print STDERR "\n"; + print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n"; + print STDERR " \$directories{SRCTEST} = \"$directories{SRCTEST}\"\n"; + print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n"; + print STDERR " \$directories{RESULTS} = \"$directories{RESULTS}\"\n"; + print STDERR " \$directories{BLDAPPS} = \"$directories{BLDAPPS}\"\n"; + print STDERR " \$directories{SRCAPPS} = \"$directories{SRCAPPS}\"\n"; + print STDERR " \$directories{SRCTOP} = \"$directories{SRCTOP}\"\n"; + print STDERR " \$directories{BLDTOP} = \"$directories{BLDTOP}\"\n"; print STDERR "\n"; - print STDERR " current directory is \"",curdir(),"\"\n"; print STDERR " the way back is \"$reverse\"\n"; } |