View Single Post
Cpp Cpp's Avatar

JCF Member

Joined: Mar 2001

Posts: 1,557

Cpp is doing well so far

May 6, 2009, 12:34 PM
Cpp is offline
Reply With Quote
Ah, now I understand your problem. You're not using the zlib library and/or C++ language. Personally I am not sure how the code you're using works, but I've checked the zlib source code and apparently the crc32 function always returns zero when the buffer param is set to Z_NULL. So in this case crc32(0L, Z_NULL, 0) = 0. If you pass a zero to your function, it won't work?

Code:
unsigned long ZEXPORT crc32(crc, buf, len)
    unsigned long crc;
    const unsigned char FAR *buf;
    unsigned len;
{
    if (buf == Z_NULL) return 0UL;

#ifdef DYNAMIC_CRC_TABLE
    if (crc_table_empty)
        make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */

#ifdef BYFOUR
    if (sizeof(void *) == sizeof(ptrdiff_t)) {
        u4 endian;

        endian = 1;
        if (*((unsigned char *)(&endian)))
            return crc32_little(crc, buf, len);
        else
            return crc32_big(crc, buf, len);
    }
#endif /* BYFOUR */
    crc = crc ^ 0xffffffffUL;
    while (len >= 8) {
        DO8;
        len -= 8;
    }
    if (len) do {
        DO1;
    } while (--len);
    return crc ^ 0xffffffffUL;
}
__________________
<a href="http://nmap.org/"><img border="0" alt="Nmap Security Scanner" src="http://images.insecure.org/nmap/images/prop/nmap_bnr_matrix_pfos.gif"/></a>