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 <[email protected]>
Co-authored-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1ecc48b9bcc377df867de3957d3abfbe5c14c2f9

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(-)

Reply via email to