Message120114
zlib.crc32() and zlib.adler32() in Modules/zlibmodule.c don't handle buffers of >=4GB correctly. The length of a Py_buffer is of type Py_ssize_t, while the C zlib functions take length as an unsigned integer. This means that on a 64-bit build, the buffer length gets silently truncated to 32 bits, which results in incorrect output for large inputs.
Attached is a patch that fixes this by computing the checksum incrementally, using small-enough chunks of the buffer.
A better fix might be to have Modules/zlib/crc32.c use 64-bit lengths. I tried this, but I couldn't get it to work. It seems that if the system already has zlib installed, Python will link against the existing version instead of compiling its own.
Testing this might be a bit tricky. Allocating a 4+GB regular buffer isn't practical. Using a memory-mapped file would work, but I'm not sure having a unit test create a multi-gigabyte file is a great thing to do. |
|
Date |
User |
Action |
Args |
2010-11-01 09:46:05 | nadeem.vawda | set | recipients:
+ nadeem.vawda |
2010-11-01 09:46:05 | nadeem.vawda | set | messageid: <1288604765.69.0.684600327936.issue10276@psf.upfronthosting.co.za> |
2010-11-01 09:46:03 | nadeem.vawda | link | issue10276 messages |
2010-11-01 09:46:02 | nadeem.vawda | create | |
|