[openssl] master update

Richard Levitte levitte at openssl.org
Thu Jun 10 15:59:58 UTC 2021


The branch master has been updated
       via  7afef721ff93018a66f8e2e6b9e1ce3d48321bdf (commit)
      from  ef0449135c4e4e7f04bbeafbd76ce7b5c0518088 (commit)


- Log -----------------------------------------------------------------
commit 7afef721ff93018a66f8e2e6b9e1ce3d48321bdf
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Jun 10 16:43:27 2021 +0200

    OpenSSL::Test: If __cwd() is to create the directory, do it early
    
    This is to ensure that abs_path() has an existing directory to look at.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15701)

-----------------------------------------------------------------------

Summary of changes:
 util/perl/OpenSSL/Test.pm | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm
index 00db3d41c8..00aa4d841e 100644
--- a/util/perl/OpenSSL/Test.pm
+++ b/util/perl/OpenSSL/Test.pm
@@ -1124,6 +1124,14 @@ sub __data_dir {
 sub __cwd {
     my $dir = catdir(shift);
     my %opts = @_;
+
+    # If the directory is to be created, we must do that before using
+    # abs_path().
+    $dir = canonpath($dir);
+    if ($opts{create}) {
+	mkpath($dir);
+    }
+
     my $abscurdir = abs_path(curdir());
     my $absdir = abs_path($dir);
     my $reverse = abs2rel($abscurdir, $absdir);
@@ -1143,11 +1151,6 @@ sub __cwd {
     # In this case, we won't even clean it out, for safety's sake.
     return "." if $reverse eq "";
 
-    $dir = canonpath($dir);
-    if ($opts{create}) {
-	mkpath($dir);
-    }
-
     # We are recalculating the directories we keep track of, but need to save
     # away the result for after having moved into the new directory.
     my %tmp_directories = ();
@@ -1160,11 +1163,10 @@ sub __cwd {
     foreach (@dirtags) {
 	if (!file_name_is_absolute($directories{$_})) {
 	    my $oldpath = abs_path($directories{$_});
-	    my $newbase = abs_path($dir);
-	    my $newpath = abs2rel($oldpath, $newbase);
+	    my $newpath = abs2rel($oldpath, $absdir);
 	    if ($debug) {
 		print STDERR "DEBUG: [dir $_] old path: $oldpath\n";
-		print STDERR "DEBUG: [dir $_] new base: $newbase\n";
+		print STDERR "DEBUG: [dir $_] new base: $absdir\n";
 		print STDERR "DEBUG: [dir $_] resulting new path: $newpath\n";
 	    }
 	    $tmp_directories{$_} = $newpath;
@@ -1177,11 +1179,10 @@ sub __cwd {
     foreach (@direnv) {
 	if (!file_name_is_absolute($ENV{$_})) {
 	    my $oldpath = abs_path($ENV{$_});
-	    my $newbase = abs_path($dir);
-	    my $newpath = abs2rel($oldpath, $newbase);
+	    my $newpath = abs2rel($oldpath, $absdir);
 	    if ($debug) {
 		print STDERR "DEBUG: [env $_] old path: $oldpath\n";
-		print STDERR "DEBUG: [env $_] new base: $newbase\n";
+		print STDERR "DEBUG: [env $_] new base: $absdir\n";
 		print STDERR "DEBUG: [env $_] resulting new path: $newpath\n";
 	    }
 	    $tmp_ENV{$_} = $newpath;


More information about the openssl-commits mailing list