pgsql: Fix detection of truncated zstd and LZ4 dump data

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix detection of truncated zstd and LZ4 dump data
Date: 2026-10-09 11:43:13
Message-ID: E1xF90L-00000000wPq-42oQ@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix detection of truncated zstd and LZ4 dump data

pg_restore did not verify that zstd and LZ4 decompression completed
the final frame when reading custom and directory-format dumps. As a
result, it could accept a dump whose compressed data was truncated.

Track final-frame completion and reject incomplete compressed input.
For zstd, flush any internally buffered output before performing the
final check.

Add regression tests for truncated zstd and LZ4 data in custom and
directory-format dumps and also address a potentially empty error
message while in there.

Author: Chao Li <lic(at)highgo(dot)com>
Co-authored-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://postgr.es/m/5962B878-C43D-4EBC-9E95-1F945CE5E586@gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e01fc6315f19a794301ca8889d37ae629862e2ac

Modified Files
--------------
src/bin/pg_dump/compress_gzip.c | 6 +-
src/bin/pg_dump/compress_lz4.c | 30 ++++++-
src/bin/pg_dump/compress_zstd.c | 67 ++++++++++++++-
src/bin/pg_dump/t/006_pg_dump_compress.pl | 136 ++++++++++++++++++++++++++++++
4 files changed, 233 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-10-09 11:43:31 pgsql: Fix detection of truncated zstd and LZ4 dump data
Previous Message Michael Paquier 2026-10-09 05:00:18 pgsql: Treat any negative ws_file as closed in xlogreader.c