ICRAR / crc32c

A python package implementing the crc32c algorithm in hardware and software
GNU Lesser General Public License v2.1
41 stars 25 forks source link

Fix char signedness issue in _crc32c_sw_slicing_by_8() #44

Closed mgorny closed 4 months ago

mgorny commented 4 months ago

Fix _crc32c_sw_slicing_by_8() to use unsigned char for p_buf, to fix incorrect results on platforms with signed char such as SPARC. The code has been casting unsigned char * to char * for no apparent reason, and this broke the bitshifts in the big endian blocks.

Particularly,

crc ^= *(p_buf++) << 16

would be XOR-ed against 0xffee0000 rather than 0x00ee0000.

Fixes #43

rtobar commented 4 months ago

Thanks @mgorny, not only for the PR, but also for reporting the issue and doing the root-cause analysis. Changes look fine to me, I agree the cast was completely unnecessary. I'll tag a release shortly.

rtobar commented 4 months ago

@mgorny 2.4.1 has been tagged, a new release will hopefully appear automatically in PyPI in an hour or less; otherwise tomorrow I'll have a look.

mgorny commented 4 months ago

Thanks!