From 5c00f4e2e3bcee6931ae93429d53f7c2a4f46156 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 13 May 2026 14:43:52 +0900 Subject: [PATCH] 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 --- src/test/regress/input/compression_pglz.source | 10 ++++++++++ src/test/regress/output/compression_pglz.source | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/test/regress/input/compression_pglz.source b/src/test/regress/input/compression_pglz.source index 499ac4cee59..90eee2034cb 100644 --- a/src/test/regress/input/compression_pglz.source +++ b/src/test/regress/input/compression_pglz.source @@ -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; diff --git a/src/test/regress/output/compression_pglz.source b/src/test/regress/output/compression_pglz.source index 910a20acf06..b46632842d8 100644 --- a/src/test/regress/output/compression_pglz.source +++ b/src/test/regress/output/compression_pglz.source @@ -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;