-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid CRC for framing modes #25
Comments
Also, for quick reference, the CRC-32 section of the current |
The plot thickens. Upon further inspection, I believe the implementation here is indeed correct and it's the Mozilla repo which is at fault. I also erroneously claimed that Specifically, the formal spec of Line 15 in 809c6f2
References:
However this still creates a small pickle, as there is now technically another "flavour" for this single compression format. Given that the difference is so small, I would hesitate to create an entirely new format such as |
I made a small program to compare the results of the implementation with CRC examples. $ git clone https://github.com/kubo/snzip.git
$ cd snzip
$ ./autogen.sh
$ ./configure
$ wget https://gist.githubusercontent.com/kubo/c6bc9f038e3dd66bfb37da4f8596d119/raw/b97e2a7d325fc15edbc149a036f0605f79a2e22d/crc32_test.c
...omitted...
$ gcc -o crc32_test crc32_test.c crc32.c crc32_sse4_2.c -msse4.2
$ ./crc32_test
32 bytes of zeroes: OK
32 bytes of ones: OK
32 bytes of incrementing 00..1f: OK
32 bytes of decrementing 1f..00: OK
An iSCSI - SCSI Read (10) Command PDU: OK The results are same with the CRC examples. As for your two ideas, I prefer the former. However I postpone my decision for a while. |
snzip/crc32.h
Line 15 in 809c6f2
It would appear that while calculating the masked CRC in the function above, you perform a bitwise NOT operator on the result before masking. I'm unsure what formats require this, if any (possibly
snappy-in-java
), but this creates a mismatched CRC for most other public implementations offraming2
. Specifically:python-snappy
library : https://github.com/andrix/python-snappy/blob/3c9cad5e82c48416c930e70ae21cc7a0ee693a6f/snappy/snappy.py#L67I was hesitant to make a PR until I verified which formats might require it, but it should be an easy fix (I'd be happy to do it). Possibly two different functions, one which inverts and one which does not.
The text was updated successfully, but these errors were encountered: