From: Michael Paquier Date: Wed, 13 May 2026 05:43:42 +0000 (+0900) Subject: Add more tests for corrupted data with pglz_decompress() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=900c07b854a7d7549ea4116aaafbb02bc610553a;p=thirdparty%2Fpostgresql.git Add more tests for corrupted data with pglz_decompress() Two cases fixed by 2b5ba2a0a141 were not covered, to emulate the handling of corrupted data, for: - set control bit with a valid 2-byte match tag where offset is 0. - set control bit with a valid 2-byte match tag where offset exceeds output written. Oversight in 67d318e70402. Reviewed-by: Ayush Tiwari Discussion: https://postgr.es/m/agF4xkIdRcrCIprs@paquier.xyz Backpatch-through: 14 --- diff --git a/src/test/regress/expected/compression_pglz.out b/src/test/regress/expected/compression_pglz.out index 0ef49d42506..066a3317c65 100644 --- a/src/test/regress/expected/compression_pglz.out +++ b/src/test/regress/expected/compression_pglz.out @@ -60,6 +60,18 @@ SELECT test_pglz_decompress('\x010f01'::bytea, 1024, false); ERROR: pglz_decompress failed SELECT test_pglz_decompress('\x010f01'::bytea, 1024, true); ERROR: pglz_decompress failed +-- Corrupted compressed data. Set control bit with a valid 2-byte match +-- tag where offset exceeds output written. +SELECT test_pglz_decompress('\x011001'::bytea, 1024, false); +ERROR: pglz_decompress failed +SELECT test_pglz_decompress('\x011001'::bytea, 1024, true); +ERROR: pglz_decompress failed +-- Corrupted compressed data. Set control bit with a valid 2-byte match +-- tag where offset is 0. +SELECT test_pglz_decompress('\x010300'::bytea, 1024, false); +ERROR: pglz_decompress failed +SELECT test_pglz_decompress('\x010300'::bytea, 1024, true); +ERROR: pglz_decompress failed -- Clean up DROP FUNCTION test_pglz_compress; DROP FUNCTION test_pglz_decompress; diff --git a/src/test/regress/sql/compression_pglz.sql b/src/test/regress/sql/compression_pglz.sql index a44af02afb7..dbd37f7d4eb 100644 --- a/src/test/regress/sql/compression_pglz.sql +++ b/src/test/regress/sql/compression_pglz.sql @@ -48,6 +48,16 @@ SELECT test_pglz_decompress('\x01ff'::bytea, 1024, true); SELECT test_pglz_decompress('\x010f01'::bytea, 1024, false); SELECT test_pglz_decompress('\x010f01'::bytea, 1024, true); +-- Corrupted compressed data. Set control bit with a valid 2-byte match +-- tag where offset exceeds output written. +SELECT test_pglz_decompress('\x011001'::bytea, 1024, false); +SELECT test_pglz_decompress('\x011001'::bytea, 1024, true); + +-- Corrupted compressed data. Set control bit with a valid 2-byte match +-- tag where offset is 0. +SELECT test_pglz_decompress('\x010300'::bytea, 1024, false); +SELECT test_pglz_decompress('\x010300'::bytea, 1024, true); + -- Clean up DROP FUNCTION test_pglz_compress; DROP FUNCTION test_pglz_decompress;