lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.03k stars 420 forks source link

Set hard limit for image buffer size #171

Open hpjansson opened 2 years ago

hpjansson commented 2 years ago

A security researcher found that it was possible to make lodepng allocate a terabyte or more of memory by supplying bogus image dimensions. This adds a compiled-in upper limit on the size of the allocation for uncompressed image data.

Maybe you want this to be configurable at runtime (possibly by generalizing zlibsettings->max_output_size). Any solution works for me as long as it's possible to specify a limit :-)