scottmac                Thu Sep 18 11:59:13 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/hash/tests     mhash_004.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/hash   hash.c 
    /php-src/ext/hash/tests     mhash_001.phpt 
  Log:
  MFH: mhash algorithm parameter was modified when it was a zval, also update a 
test.
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.324&r2=1.2027.2.547.2.965.2.325&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.324 
php-src/NEWS:1.2027.2.547.2.965.2.325
--- php-src/NEWS:1.2027.2.547.2.965.2.324       Thu Sep 18 11:49:36 2008
+++ php-src/NEWS        Thu Sep 18 11:59:13 2008
@@ -6,6 +6,8 @@
 - Changed error level E_ERROR into E_WARNING in Soap extension methods 
   parameter validation. (Felipe)
 
+- Fixed bug causing the algorithm parameter of mhash() to be modified. (Scott)
+
 - Fixed bug #46106 (Memory leaks when using global statement). (Dmitry)
 - Fixed bug #46099 (Xsltprocessor::setProfiling - memory leak). (Felipe, Rob).
 - Fixed bug #46087 (DOMXPath - segfault on destruction of a cloned object).
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.18.2.5.2.7.2.10&r2=1.18.2.5.2.7.2.11&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.18.2.5.2.7.2.10 
php-src/ext/hash/hash.c:1.18.2.5.2.7.2.11
--- php-src/ext/hash/hash.c:1.18.2.5.2.7.2.10   Sat Jul  5 00:28:16 2008
+++ php-src/ext/hash/hash.c     Thu Sep 18 11:59:13 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash.c,v 1.18.2.5.2.7.2.10 2008/07/05 00:28:16 scottmac Exp $ */
+/* $Id: hash.c,v 1.18.2.5.2.7.2.11 2008/09/18 11:59:13 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -626,20 +626,22 @@
 
 PHP_FUNCTION(mhash)
 {
-       zval *z_algorithm;
-       int algorithm;
+       zval **z_algorithm;
+       long algorithm;
 
-       if (zend_parse_parameters(1 TSRMLS_CC, "z", &z_algorithm) == FAILURE) {
+       if (zend_parse_parameters(1 TSRMLS_CC, "Z", &z_algorithm) == FAILURE) {
                return;
        }
 
-       algorithm = Z_LVAL_P(z_algorithm);
+       SEPARATE_ZVAL(z_algorithm);
+       convert_to_long_ex(z_algorithm);
+       algorithm = Z_LVAL_PP(z_algorithm);
 
        /* need to conver the first parameter from int to string */
        if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) {
                struct mhash_bc_entry algorithm_lookup = 
mhash_to_hash[algorithm];
                if (algorithm_lookup.hash_name) {
-                       ZVAL_STRING(z_algorithm, algorithm_lookup.hash_name, 1);
+                       ZVAL_STRING(*z_algorithm, algorithm_lookup.hash_name, 
1);
                }
        }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/mhash_001.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/hash/tests/mhash_001.phpt
diff -u php-src/ext/hash/tests/mhash_001.phpt:1.1.2.1 
php-src/ext/hash/tests/mhash_001.phpt:1.1.2.2
--- php-src/ext/hash/tests/mhash_001.phpt:1.1.2.1       Thu Jun 26 22:33:16 2008
+++ php-src/ext/hash/tests/mhash_001.phpt       Thu Sep 18 11:59:13 2008
@@ -33,7 +33,7 @@
                echo "$hash: ";
                var_dump($wanted);
                echo "$hash: ";
-               var_dump($result);
+               var_dump(bin2hex($result));
        }
        echo "\n";
 }

http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/mhash_004.phpt?view=markup&rev=1.1
Index: php-src/ext/hash/tests/mhash_004.phpt
+++ php-src/ext/hash/tests/mhash_004.phpt
--TEST--
mhash() modifying algorithm parameter
--INI--
magic_quotes_runtime=0
--SKIPIF--
<?php
        include "skip_mhash.inc";
?>
--FILE--
<?php

$algo = MHASH_MD5;
var_dump($algo);
var_dump(bin2hex(mhash($algo, "test")));
var_dump($algo);

?>
--EXPECT--
int(1)
unicode(32) "098f6bcd4621d373cade4e832627b4f6"
int(1)



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

Reply via email to