[vector-paint-pdf] Fix use-of-uninitialized in indexed smask

inflate() with Z_FINISH can return Z_STREAM_END after
decompressing fewer bytes than the expected raw_len when
the IDAT data is truncated or the width/height don't match
the actual compressed payload.  The un-filter loop then
reads uninitialized tail bytes from the raw buffer.

Check that stream.total_out matches raw_len after inflate;
bail out if the sizes disagree.

Fixes: https://oss-fuzz.com/testcase-detail/5190826362994688

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-16 16:32:38 -06:00
1 parent 3c5352badd
commit 68afee084c
1 file changed
+2 -1
+2 -1
View File
@@ -531,8 +531,9 @@ hb_pdf_build_indexed_smask (hb_vector_t<char> *out,
if (inflateInit (&stream) != Z_OK)
return false;
int status = inflate (&stream, Z_FINISH);
unsigned long total_out = stream.total_out;
inflateEnd (&stream);
if (status != Z_STREAM_END)
if (status != Z_STREAM_END || total_out != raw_len)
return false;
/* Un-filter and map to alpha. */