Skip to content

Commit 374cab6

Browse files
mpeylolevitte
authored andcommitted
Adding Test.pm with workaround for Perl abs2rel bug
If SRCTOP != BLDTOP, and SRCTOP is given in relative form, e.g. "./config ../openssl", then a bug in Perl's abs2rel may trigger that directory- rewriting in __cwd results in wrong entries in %directories under certain circumstances, e.g. when a test executes run(app(["openssl"]) after indir. There should not be any need to go to a higher directory from BLDDIR or SRCDIR, so it should be OK to use them in their absolute form, also resolving all possible symlinks, right from the start. Following the File::Spec::Functions bug description (reported to perl.org): When abs2rel gets a path argument with ..s that are crossing over the ..s trailing the base argument, the result is wrong. Example PATH: /home/goal/test/.. BASE: /home/goal/test/../../base Good result: ../goal Bad result: ../.. Bug verified with File::Spec versions - 3.6301 - 3.74 (latest) Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from #7031) (cherry picked from commit 7a20272)
1 parent 42180a2 commit 374cab6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

util/perl/OpenSSL/Test.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use File::Spec::Functions qw/file_name_is_absolute curdir canonpath splitdir
6565
rel2abs/;
6666
use File::Path 2.00 qw/rmtree mkpath/;
6767
use File::Basename;
68+
use Cwd qw/abs_path/;
6869

6970
my $level = 0;
7071

@@ -869,8 +870,8 @@ failures will result in a C<BAIL_OUT> at the end of its run.
869870
sub __env {
870871
(my $recipe_datadir = basename($0)) =~ s/\.t$/_data/i;
871872

872-
$directories{SRCTOP} = $ENV{SRCTOP} || $ENV{TOP};
873-
$directories{BLDTOP} = $ENV{BLDTOP} || $ENV{TOP};
873+
$directories{SRCTOP} = abs_path($ENV{SRCTOP} || $ENV{TOP});
874+
$directories{BLDTOP} = abs_path($ENV{BLDTOP} || $ENV{TOP});
874875
$directories{BLDAPPS} = $ENV{BIN_D} || __bldtop_dir("apps");
875876
$directories{SRCAPPS} = __srctop_dir("apps");
876877
$directories{BLDFUZZ} = __bldtop_dir("fuzz");

0 commit comments

Comments
 (0)