]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add more tests for corrupted data with pglz_decompress()
authorMichael Paquier <michael@paquier.xyz>
Wed, 13 May 2026 05:43:52 +0000 (14:43 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 13 May 2026 05:43:52 +0000 (14:43 +0900)
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 <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/agF4xkIdRcrCIprs@paquier.xyz
Backpatch-through: 14

src/test/regress/input/compression_pglz.source
src/test/regress/output/compression_pglz.source

index 499ac4cee59f0c82578f699f4cd8ab5a8fd3d586..90eee2034cb773f70381c0f59774811d2fe4828e 100644 (file)
@@ -42,6 +42,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;
index 910a20acf06055765afb763fce6a32e3bd18f506..b46632842d83e12ca4429aa9e9733f73cf84cf48 100644 (file)
@@ -56,6 +56,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;