pajoye                                   Tue, 24 May 2011 13:48:04 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=311390

Log:
- Fix #54721, different Hashes on Windows, BSD and Linux on wrong Salt size

Bug: http://bugs.php.net/54721 (Feedback) crypt function 
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/standard/php_crypt_r.c
    A   php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54721.phpt
    U   php/php-src/branches/PHP_5_4/ext/standard/php_crypt_r.c
    A   php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug54721.phpt
    U   php/php-src/trunk/ext/standard/php_crypt_r.c
    A   php/php-src/trunk/ext/standard/tests/strings/bug54721.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-05-24 13:44:57 UTC (rev 311389)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-05-24 13:48:04 UTC (rev 311390)
@@ -37,8 +37,10 @@
     (tomas dot brastavicius at quantum dot lt, Pierrick)
   . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
     TMPDIR on Windows). (Pierre)
-  . Fixed bug 54866 (incorrect accounting for realpath_cache_size) (Dustin 
Ward)
-
+  . Fixed bug #54866 (incorrect accounting for realpath_cache_size) (Dustin 
Ward)
+  . Fixed bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt 
size)
+    (Pierre, os at irj dot ru)
+
 - Apache2 Handler SAPI:
   . Fixed bug #54529 (SAPI crashes on apache_config.c:197).
     (hebergement at riastudio dot fr)

Modified: php/php-src/branches/PHP_5_3/ext/standard/php_crypt_r.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/php_crypt_r.c     2011-05-24 
13:44:57 UTC (rev 311389)
+++ php/php-src/branches/PHP_5_3/ext/standard/php_crypt_r.c     2011-05-24 
13:48:04 UTC (rev 311390)
@@ -197,7 +197,7 @@
                goto _destroyCtx1;
        }

-       dwHashLen = pwl + sl + pwl;
+       dwHashLen = 16;
        CryptGetHashParam(ctx1, HP_HASHVAL, final, &dwHashLen, 0);
        /*  MD5(pw,salt,pw). Valid. */


Added: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54721.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54721.phpt       
                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54721.phpt       
2011-05-24 13:48:04 UTC (rev 311390)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt size)
+--FILE--
+<?php
+echo crypt("", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("b", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bu", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bug", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("pass", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("buged", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("aaaaaaaaaaaaaaaaaaaaaaaaa ", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') 
. "\n";
+?>
+--EXPECT--
+$1$dW0.is5.$I0iqTYHPzkP4YnRgnXxZW0
+$1$dW0.is5.$KaspRpPQ9U7Xb5Vv5c.WE/
+$1$dW0.is5.$X9G1x/Ep8zYQSrU4/lKUg.
+$1$dW0.is5.$wE5Rz/HxPtDMfqil6kK980
+$1$dW0.is5.$2E4/ZDY1vr73HqLl1bLs9.
+$1$dW0.is5.$lvGhphTQwqgKxWhWwYERr1
+$1$dW0.is5.$XzsWcLSBj2BvhOKH0xdpZ0

Modified: php/php-src/branches/PHP_5_4/ext/standard/php_crypt_r.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/php_crypt_r.c     2011-05-24 
13:44:57 UTC (rev 311389)
+++ php/php-src/branches/PHP_5_4/ext/standard/php_crypt_r.c     2011-05-24 
13:48:04 UTC (rev 311390)
@@ -197,7 +197,7 @@
                goto _destroyCtx1;
        }

-       dwHashLen = pwl + sl + pwl;
+       dwHashLen = 16;
        CryptGetHashParam(ctx1, HP_HASHVAL, final, &dwHashLen, 0);
        /*  MD5(pw,salt,pw). Valid. */


Added: php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug54721.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug54721.phpt       
                        (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug54721.phpt       
2011-05-24 13:48:04 UTC (rev 311390)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt size)
+--FILE--
+<?php
+echo crypt("", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("b", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bu", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bug", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("pass", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("buged", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("aaaaaaaaaaaaaaaaaaaaaaaaa ", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') 
. "\n";
+?>
+--EXPECT--
+$1$dW0.is5.$I0iqTYHPzkP4YnRgnXxZW0
+$1$dW0.is5.$KaspRpPQ9U7Xb5Vv5c.WE/
+$1$dW0.is5.$X9G1x/Ep8zYQSrU4/lKUg.
+$1$dW0.is5.$wE5Rz/HxPtDMfqil6kK980
+$1$dW0.is5.$2E4/ZDY1vr73HqLl1bLs9.
+$1$dW0.is5.$lvGhphTQwqgKxWhWwYERr1
+$1$dW0.is5.$XzsWcLSBj2BvhOKH0xdpZ0

Modified: php/php-src/trunk/ext/standard/php_crypt_r.c
===================================================================
--- php/php-src/trunk/ext/standard/php_crypt_r.c        2011-05-24 13:44:57 UTC 
(rev 311389)
+++ php/php-src/trunk/ext/standard/php_crypt_r.c        2011-05-24 13:48:04 UTC 
(rev 311390)
@@ -197,7 +197,7 @@
                goto _destroyCtx1;
        }

-       dwHashLen = pwl + sl + pwl;
+       dwHashLen = 16;
        CryptGetHashParam(ctx1, HP_HASHVAL, final, &dwHashLen, 0);
        /*  MD5(pw,salt,pw). Valid. */


Added: php/php-src/trunk/ext/standard/tests/strings/bug54721.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/strings/bug54721.phpt                  
        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/strings/bug54721.phpt  2011-05-24 
13:48:04 UTC (rev 311390)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt size)
+--FILE--
+<?php
+echo crypt("", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("b", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bu", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("bug", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("pass", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("buged", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') . "\n";
+echo crypt("aaaaaaaaaaaaaaaaaaaaaaaaa ", '$1$dW0.is5.$10CH101gGOr1677ZYd517.') 
. "\n";
+?>
+--EXPECT--
+$1$dW0.is5.$I0iqTYHPzkP4YnRgnXxZW0
+$1$dW0.is5.$KaspRpPQ9U7Xb5Vv5c.WE/
+$1$dW0.is5.$X9G1x/Ep8zYQSrU4/lKUg.
+$1$dW0.is5.$wE5Rz/HxPtDMfqil6kK980
+$1$dW0.is5.$2E4/ZDY1vr73HqLl1bLs9.
+$1$dW0.is5.$lvGhphTQwqgKxWhWwYERr1
+$1$dW0.is5.$XzsWcLSBj2BvhOKH0xdpZ0

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to