mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:27:42 +00:00
LibGfx: Let the PNG decoder fail if the header is missing or too short
This commit is contained in:
parent
992467cca3
commit
4393a2a96d
1 changed files with 6 additions and 0 deletions
|
@ -419,6 +419,12 @@ static bool decode_png_header(PNGLoadingContext& context)
|
||||||
if (context.state >= PNGLoadingContext::HeaderDecoded)
|
if (context.state >= PNGLoadingContext::HeaderDecoded)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!context.data || context.data_size < sizeof(png_header)) {
|
||||||
|
dbg() << "Missing PNG header";
|
||||||
|
context.state = PNGLoadingContext::State::Error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (memcmp(context.data, png_header, sizeof(png_header)) != 0) {
|
if (memcmp(context.data, png_header, sizeof(png_header)) != 0) {
|
||||||
dbg() << "Invalid PNG header";
|
dbg() << "Invalid PNG header";
|
||||||
context.state = PNGLoadingContext::State::Error;
|
context.state = PNGLoadingContext::State::Error;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue