Browse Source

MFH: fix bug #45028 (CRC32 output endianness is different between crc32() and hash())

PHP-5.2.1RC1
Antony Dovgal 18 years ago
parent
commit
79b6a241ab
  1. 2
      NEWS
  2. 12
      ext/hash/hash_crc32.c
  3. 12
      ext/hash/tests/crc32.phpt

2
NEWS

@ -59,6 +59,8 @@ PHP NEWS
(Dmitry)
- Fixed bug #45139 (ReflectionProperty returns incorrect declaring class).
(Felipe)
- Fixed bug #45028 (CRC32 output endianness is different between crc32()
and hash()). (Tony)
- Fixed bug #45004 (pg_insert() does not accept 4 digit timezone format).
(Ilia)
- Fixed bug #44891 Memory leak using registerPHPFunctions and XSLT Variable

12
ext/hash/hash_crc32.c

@ -56,6 +56,16 @@ PHP_HASH_API void PHP_CRC32Final(unsigned char digest[4], PHP_CRC32_CTX *context
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;
}
const php_hash_ops php_hash_crc32_ops = {
(php_hash_init_func_t) PHP_CRC32Init,
(php_hash_update_func_t) PHP_CRC32Update,
@ -68,7 +78,7 @@ const php_hash_ops php_hash_crc32_ops = {
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,
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX)

12
ext/hash/tests/crc32.phpt

@ -28,9 +28,9 @@ echo hash('crc32b', '12345678901234567890123456789012345678901234567890123456789
882174a0
96790816
00000000
43beb7e8
c2412435
7f9d1520
bd50274c
d2e6c21f
724aa97c
e8b7be43
352441c2
20159d7f
4c2750bd
1fc2e6d2
7ca94a72
Loading…
Cancel
Save