734417
From 5984f005f7a08feca52509658cff1c56d768e057 Mon Sep 17 00:00:00 2001
734417
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
734417
Date: Mon, 1 Dec 2014 15:28:36 +0100
734417
Subject: [PATCH] t/op/taint.t: Perform SHA-256 algorithm by crypt() if default
734417
 one is disabled
734417
MIME-Version: 1.0
734417
Content-Type: text/plain; charset=UTF-8
734417
Content-Transfer-Encoding: 8bit
734417
734417
The crypt(3) call may return NULL. This is the case on FIPS-enabled
734417
platforms. Then "tainted crypt" test would fail.
734417
734417
See RT#121591 for similar fix in t/op/crypt.t.
734417
734417
Signed-off-by: Petr Písař <ppisar@redhat.com>
734417
734417
Petr Pisar: Ported to 5.16.3.
734417
734417
Signed-off-by: Petr Písař <ppisar@redhat.com>
734417
---
734417
 t/op/taint.t | 14 +++++++++++++-
734417
 1 file changed, 13 insertions(+), 1 deletion(-)
734417
734417
diff --git a/t/op/taint.t b/t/op/taint.t
734417
index 9cea740..478e574 100644
734417
--- a/t/op/taint.t
734417
+++ b/t/op/taint.t
734417
@@ -1868,7 +1868,19 @@ foreach my $ord (78, 163, 256) {
734417
 
734417
 {
734417
     # 59998
734417
-    sub cr { my $x = crypt($_[0], $_[1]); $x }
734417
+    sub cr {
734417
+        # On platforms implementing FIPS mode, using a weak algorithm
734417
+        # (including the default triple-DES algorithm) causes crypt(3) to
734417
+        # return a null pointer, which Perl converts into undef. We assume
734417
+        # for now that all such platforms support glibc-style selection of
734417
+        # a different hashing algorithm.
734417
+        my $alg = '';       # Use default algorithm
734417
+        if ( !defined(crypt("ab", "cd")) ) {
734417
+            $alg = '$5$';   # Use SHA-256
734417
+        }
734417
+        my $x = crypt($_[0], $alg . $_[1]);
734417
+        $x
734417
+    }
734417
     sub co { my $x = ~$_[0]; $x }
734417
     my ($a, $b);
734417
     $a = cr('hello', 'foo' . $TAINT);
734417
-- 
734417
1.9.3
734417