[OpenJDK 2D-Dev] 6782079: PNG: reading metadata may cause OOM on truncated images

Martin von Gagern Martin.vGagern at gmx.net
Mon Dec 15 15:41:29 UTC 2008


Andrew Brygin wrote:
> yes, I agree that the reaching the length limit likely signifies that
> png header is corrupt. Our usual policy is to try to be tolerant to
> errors in the images. There are too many not very well formed images
> around and being too strict we may reject too much. That's why I am
> inclined to avoid throwing exception.

A malformed string will in almost all cases render the current chunk
unusable. So as an alternative, you could throw a (newly introduced)
MalformedChunkException and catch such an exception in the loop
iterating over the chunks. This way, overlong strings and the resulting
loss of synchronization could never lead to the allocation of
unreasonable amounts of data or similar issue, as the broken chunk would
be aborted cleanly. Just an idea.

Greetings,
 Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20081215/94d55e11/signature.asc>


More information about the 2d-dev mailing list