Quellcode durchsuchen

LibGfx: Let the PNG decoder fail if the header is missing or too short

Andreas Kling vor 5 Jahren
Ursprung
Commit
4393a2a96d
1 geänderte Dateien mit 6 neuen und 0 gelöschten Zeilen
  1. 6 0
      Libraries/LibGfx/PNGLoader.cpp

+ 6 - 0
Libraries/LibGfx/PNGLoader.cpp

@@ -419,6 +419,12 @@ static bool decode_png_header(PNGLoadingContext& context)
     if (context.state >= PNGLoadingContext::HeaderDecoded)
         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) {
         dbg() << "Invalid PNG header";
         context.state = PNGLoadingContext::State::Error;