[BUG][FIX][TEST] ZLibStream crc validation broken (PS. to PNGReadWriter v7)

Andreas Raab andreas.raab at gmx.de
Sun Feb 29 03:54:07 UTC 2004


> Anyway, this is stuff from highly esteemed Squeakers, and it seems to
> have been tested a bit by other people too. And if we can't trust them
> then... :)

Trust or not - it ain't working correctly ;-( Turns out that the CRC
validation is broken since a) #pastEndRead may return nil so that the crc
update is incorrectly applied to the "same bytes" multiple times and b) some
internal methods quite deliberately set the #position explicitly. What then
happens is that perfectly valid PNGs will raise crc errors.

So CRC checking needs to be added at a lower level - namely right at the
place where the data is decoded. The attached CS (which should go after V7)
addresses these issues.

"Change Set:  ZipCrcTests
Date:   29 February 2004
Author:   Andreas Raab

Integrates CRC validation at the level of InflateStream thereby avoiding
some of the problems when dealing with it in subclasses. With these changes
CRC validation is implicit - when we hit the end of a stream (such as upon
#contents, #upToEnd or similar) the CRC will be validated automatically. If
a missing or wrong crc is encountered a CRCError will be raised. Some tests
are provided to show what is expected if a missing/wrong CRC is encountered.
"

Cheers,
  - Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ZipCrcTests.2.cs
Type: application/octet-stream
Size: 15218 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040229/88eab763/ZipCrcTests.2.obj


More information about the Squeak-dev mailing list