[PATCH 2/2] windowscodecs: Disable libpng chunk size limit.

Torge Matthies openglfreak at googlemail.com
Thu Dec 2 14:44:26 CST 2021


Reading a PNG file with libpng with a chunk bigger than the 8 MiB
default chunk size limit set by libpng results in a libpng error, e.g.
"iTXt: chunk data is too large" for a too big iTXt chunk.

Fix this by disabling the chunk size limit.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52147
Signed-off-by: Torge Matthies <openglfreak at googlemail.com>
---
 dlls/windowscodecs/libpng.c          | 1 +
 dlls/windowscodecs/tests/pngformat.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/windowscodecs/libpng.c b/dlls/windowscodecs/libpng.c
index 27a735550f3..8e876b23efe 100644
--- a/dlls/windowscodecs/libpng.c
+++ b/dlls/windowscodecs/libpng.c
@@ -107,6 +107,7 @@ static HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stre
         goto end;
     }
     png_set_crc_action(png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
+    png_set_chunk_malloc_max(png_ptr, 0);
 
     /* seek to the start of the stream */
     hr = stream_seek(stream, 0, STREAM_SEEK_SET, NULL);
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index 79d8a6fbe7f..8545b9d3359 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -937,7 +937,7 @@ static void test_chunk_size(void)
     IWICBitmapDecoder *decoder;
 
     hr = create_decoder(png_8M_tEXt, sizeof(png_8M_tEXt), &decoder);
-    todo_wine ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
+    ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
     if (hr != S_OK) return;
 }
 
-- 
2.34.1




More information about the wine-devel mailing list