LibGfx: Fail PBM decode if there isn't enough color data in image

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29417
This commit is contained in:
Andreas Kling 2021-01-11 19:24:54 +01:00
parent e1cc2acded
commit 04c6245fe8
Notes: sideshowbarker 2024-07-18 23:56:26 +09:00

View file

@ -101,6 +101,12 @@ static bool read_image_data(PBMLoadingContext& context, Streamer& streamer)
}
}
size_t context_size = (u32)context.width * (u32)context.height;
if (context_size != color_data.size()) {
dbgln("Not enough color data in image.");
return false;
}
if (!create_bitmap(context)) {
return false;
}