]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix heap-buffer-overflow in pglz_decompress() on corrupt input.
authorAndrew Dunstan <andrew@dunslane.net>
Thu, 9 Apr 2026 15:48:55 +0000 (11:48 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Fri, 10 Apr 2026 14:22:48 +0000 (10:22 -0400)
commitde32a01e7bb905b455d1a001b011433bd41dfb6a
tree0c4cb1c2a64f05535c809f201b197cbe9a549eda
parenta7c41df1f2fdfba42d09a978213066d941e45c9b
Fix heap-buffer-overflow in pglz_decompress() on corrupt input.

When decoding a match tag, pglz_decompress() reads 2 bytes (or 3
for extended-length matches) from the source buffer before checking
whether enough data remains.  The existing bounds check (sp > srcend)
occurs after the reads, so truncated compressed data that ends
mid-tag causes a read past the allocated buffer.

Fix by validating that sufficient source bytes are available before
reading each part of the match tag.  The post-read sp > srcend
check is no longer needed and is removed.

Found by fuzz testing with libFuzzer and AddressSanitizer.

Backpatch-through: 14
src/common/pg_lzcompress.c