SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.26k stars 844 forks source link

Only exit JPEG scan decoding after multiple EOF hits #2701

Closed JimBobSquarePants closed 3 months ago

JimBobSquarePants commented 4 months ago

Prerequisites

Description

Fixes #2638

Updates the JpegBitReader to only exit after we've hit the end of the file multiple times. This ensures that we do not skip over the last MCU.

cc @br3aker

br3aker commented 3 months ago

Brilliant! Spent countless evenings thinking how to achieve this without sacrificing performance/DOS defense....

JimBobSquarePants commented 3 months ago

Brilliant! Spent countless evenings thinking how to achieve this without sacrificing performance/DOS defense....

I actually got the idea from changes @antonfirsov made to BufferedReadStream.