In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e7a4a717d309ed4a0cf5010654fc57f64705b1bf?hp=501b8d2373c1967286e289eee814f64b3435f325>

- Log -----------------------------------------------------------------
commit e7a4a717d309ed4a0cf5010654fc57f64705b1bf
Author: Andy Dougherty <[email protected]>
Date:   Thu Dec 31 09:01:06 2015 -0500

    [PATCH] Try more crypt algorithms in the tests, for OpenBSD.
    
    OpenBSD implements the Blowfish algorithm, but not the MD5 one used
    by glibc.   Enhance the crypt and taint tests to try both algorithms.
    If neither works, fall back to no algorithm.  The Blowfish salt
    is taken from the OpenBSD crypt(3) page.
-----------------------------------------------------------------------

Summary of changes:
 t/op/crypt.t | 14 +++++++++++---
 t/op/taint.t | 11 +++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/t/op/crypt.t b/t/op/crypt.t
index 47e546d..4e06629 100644
--- a/t/op/crypt.t
+++ b/t/op/crypt.t
@@ -33,14 +33,22 @@ BEGIN {
 # pointer, which Perl converts into undef. We assume for now that all
 # such platforms support glibc-style selection of a different hashing
 # algorithm.
+# glibc supports MD5, but OpenBSD only supports Blowfish.
 my $alg = '';       # Use default algorithm
-if ( !defined(crypt("ab", "cd")) ) {
-    $alg = '$5$';   # Use SHA-256
+if ( !defined(crypt("ab", $alg."cd")) ) {
+    $alg = '$5$';   # Try SHA-256
+}
+if ( !defined(crypt("ab", $alg."cd")) ) {
+    $alg = '$2b$12$FPWWO2RJ3CK4FINTw0Hi';  # Try Blowfish
+}
+if ( !defined(crypt("ab", $alg."cd")) ) {
+    $alg = ''; # Nothing worked.  Back to default
 }
 
 SKIP: {
     skip ("VOS crypt ignores salt.", 1) if ($^O eq 'vos');
-    ok(substr(crypt("ab", $alg."cd"), 2) ne substr(crypt("ab", $alg."ce"), 2),
+    ok(substr(crypt("ab", $alg."cd"), length($alg)+2) ne 
+       substr(crypt("ab", $alg."ce"), length($alg)+2),
        "salt makes a difference");
 }
 
diff --git a/t/op/taint.t b/t/op/taint.t
index a3cb5b6..eaee77a 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -1974,9 +1974,16 @@ foreach my $ord (78, 163, 256) {
           # return a null pointer, which Perl converts into undef. We assume
           # for now that all such platforms support glibc-style selection of
           # a different hashing algorithm.
+          # glibc supports MD5, but OpenBSD only supports Blowfish.
           my $alg = '';       # Use default algorithm
-          if ( !defined(crypt("ab", "cd")) ) {
-              $alg = '$5$';   # Use SHA-256
+          if ( !defined(crypt("ab", $alg."cd")) ) {
+              $alg = '$5$';   # Try SHA-256
+          }
+          if ( !defined(crypt("ab", $alg."cd")) ) {
+              $alg = '$2b$12$FPWWO2RJ3CK4FINTw0Hi';  # Try Blowfish
+          }
+          if ( !defined(crypt("ab", $alg."cd")) ) {
+              $alg = ''; # Nothing worked.  Back to default
           }
           my $x = crypt($_[0], $alg . $_[1]);
           $x

--
Perl5 Master Repository

Reply via email to