Open cuanduo opened 5 years ago
i think flif in image/image-png.cpp:409 png_bytep profile is not set correctly.
405 #if ((PNG_LIBPNG_VER_MAJOR << 8) | PNG_LIBPNG_VER_MINOR << 0) < \
406 ((1 << 8) | (5 << 0))
407 png_charp profile;
408 #else // >= libpng 1.5.0
409 png_bytep profile;
410 #endif
411 if (image.get_metadata("iCCP", (unsigned char **) (&profile), &length)) {
412 png_set_iCCP(png_ptr, info_ptr, (png_charp) "icc", 0, profile, length);
413 free(profile);
414 }
415 if (image.get_metadata("eXmp", (unsigned char **) (&profile), &length)) {
416 #ifdef PNG_iTXt_SUPPORTED
417 png_text txt;
418 txt.key = (png_charp) "XML:com.adobe.xmp";
419 txt.compression = PNG_ITXT_COMPRESSION_zTXt;
420 txt.text_length = 0;
421 txt.text = (png_charp) profile;
422 txt.lang = NULL;
423 txt.lang_key = NULL;
424 png_set_text(png_ptr, info_ptr, &txt, 1);
png_set_text()
expects txt.text to be NUL terminated - it calls strlen(txt.text)
to work out the length of text, but the buffer returned by image.get_metadata()
which calls lodepng_inflate()
isn't guaranteed to be NUL terminated, which causes a buffer over-read.
in my research in FLIF, a craft file can cause a heap overflow in libpng. I wonder wheather it is the bug with FLIF or libpng. flif --overwrite -d $poc out.png poc.zip
asan output