Re: The open letter to Derick Rethans <derick@php.net>

From: Date: Wed, 16 Jun 2004 14:35:04 +0000
Subject: Re: The open letter to Derick Rethans <derick@php.net>
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-10524@lists.php.net to get a copy of this message
Alexander Valyalkin wrote:
On Wed, 16 Jun 2004 12:03:36 +0200, Ard Biesheuvel <abies@php.net> wrote: Have you tested my initial re-implementation of crc32() on 64-bit architectures?
No, but I don't have to:
    register unsigned long int crc = ~0ul;
... so crc = 0xffffffffffffffff
    do {
        crc = (crc >> 8) ^ crc32tab[(crc ^ *p++) & 0xff];
        n--;
    } while (n);
... which is xor'ed with crc32tab, which has 0x00000000 in the upper halves of all its elements. This leads to the following a) the returned CRC is larger than 32 bits in the first 4 iterations, leading to incorrect results for strings of length up to 3; b) in the first couple of iterations, 1's have been shifted in instead of 0's, leading to incorrect results for strings of length 3 and up. Which means it still works for all strings of length zero. How's that for a BC break ? -- Ard

« previous php.internals (#10524) next »