From 68afee084c1e5948964b93eb69d4aeffb258028a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 16 Apr 2026 16:32:38 -0600 Subject: [PATCH] [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) --- src/hb-vector-paint-pdf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hb-vector-paint-pdf.cc b/src/hb-vector-paint-pdf.cc index 3d26d956e..1303a16c6 100644 --- a/src/hb-vector-paint-pdf.cc +++ b/src/hb-vector-paint-pdf.cc @@ -531,8 +531,9 @@ hb_pdf_build_indexed_smask (hb_vector_t *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. */