tony2001                Mon Aug 18 14:28:57 2008 UTC

  Modified files:              
    /php-src/ext/hash   hash_crc32.c 
    /php-src/ext/hash/tests     crc32.phpt hash_copy_001.phpt 
  Log:
  fix bug #45028 (CRC32 output endianness is different between crc32() and 
hash())
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_crc32.c?r1=1.7&r2=1.8&diff_format=u
Index: php-src/ext/hash/hash_crc32.c
diff -u php-src/ext/hash/hash_crc32.c:1.7 php-src/ext/hash/hash_crc32.c:1.8
--- php-src/ext/hash/hash_crc32.c:1.7   Mon Apr 21 15:37:07 2008
+++ php-src/ext/hash/hash_crc32.c       Mon Aug 18 14:28:57 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_crc32.c,v 1.7 2008/04/21 15:37:07 tony2001 Exp $ */
+/* $Id: hash_crc32.c,v 1.8 2008/08/18 14:28:57 tony2001 Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_crc32.h"
@@ -56,6 +56,16 @@
        context->state = 0;
 }
 
+PHP_HASH_API void PHP_CRC32BFinal(unsigned char digest[4], PHP_CRC32_CTX 
*context)
+{
+       context->state=~context->state;
+       digest[0] = (unsigned char) ((context->state >> 24) & 0xff);
+       digest[1] = (unsigned char) ((context->state >> 16) & 0xff);
+       digest[2] = (unsigned char) ((context->state >> 8) & 0xff);
+       digest[3] = (unsigned char) (context->state & 0xff);
+       context->state = 0;
+}
+
 PHP_HASH_API int PHP_CRC32Copy(const php_hash_ops *ops, PHP_CRC32_CTX 
*orig_context, PHP_CRC32_CTX *copy_context)
 {
        copy_context->state = orig_context->state;
@@ -75,7 +85,7 @@
 const php_hash_ops php_hash_crc32b_ops = {
        (php_hash_init_func_t) PHP_CRC32Init,
        (php_hash_update_func_t) PHP_CRC32BUpdate,
-       (php_hash_final_func_t) PHP_CRC32Final,
+       (php_hash_final_func_t) PHP_CRC32BFinal,
        (php_hash_copy_func_t) PHP_CRC32Copy,
        4, /* what to say here? */
        4,
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/crc32.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/hash/tests/crc32.phpt
diff -u php-src/ext/hash/tests/crc32.phpt:1.3 
php-src/ext/hash/tests/crc32.phpt:1.4
--- php-src/ext/hash/tests/crc32.phpt:1.3       Mon Oct  2 01:38:05 2006
+++ php-src/ext/hash/tests/crc32.phpt   Mon Aug 18 14:28:57 2008
@@ -28,9 +28,9 @@
 882174a0
 96790816
 00000000
-43beb7e8
-c2412435
-7f9d1520
-bd50274c
-d2e6c21f
-724aa97c
+e8b7be43
+352441c2
+20159d7f
+4c2750bd
+1fc2e6d2
+7ca94a72
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/hash_copy_001.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/hash/tests/hash_copy_001.phpt
diff -u php-src/ext/hash/tests/hash_copy_001.phpt:1.3 
php-src/ext/hash/tests/hash_copy_001.phpt:1.4
--- php-src/ext/hash/tests/hash_copy_001.phpt:1.3       Wed Jun  4 09:10:34 2008
+++ php-src/ext/hash/tests/hash_copy_001.phpt   Mon Aug 18 14:28:57 2008
@@ -75,8 +75,8 @@
 unicode(8) "28097c6f"
 unicode(8) "e5cfc160"
 unicode(8) "e5cfc160"
-unicode(8) "4e7a1469"
-unicode(8) "4e7a1469"
+unicode(8) "69147a4e"
+unicode(8) "69147a4e"
 unicode(32) "86362472c8895e68e223ef8b3711d8d9"
 unicode(32) "86362472c8895e68e223ef8b3711d8d9"
 unicode(40) "fabdf6905f3ba18a3c93d6a16b91e31f7222a7a4"
@@ -155,8 +155,8 @@
 unicode(8) "471714d9"
 unicode(8) "e5cfc160"
 unicode(8) "59f8d3d2"
-unicode(8) "4e7a1469"
-unicode(8) "9939e63e"
+unicode(8) "69147a4e"
+unicode(8) "3ee63999"
 unicode(32) "86362472c8895e68e223ef8b3711d8d9"
 unicode(32) "ebeeeb05c18af1e53d2d127b561d5e0d"
 unicode(40) "fabdf6905f3ba18a3c93d6a16b91e31f7222a7a4"



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

Reply via email to