pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix detection of truncated compressed backups
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix detection of truncated compressed backups
@ 2026-10-09 11:43  Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Daniel Gustafsson @ 2026-10-09 11:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix detection of truncated compressed backups

pg_verifybackup failed to detect truncated compressed tar backups
for zstd, lz4 and gzip compression.

astreamer_zstd_decompressor checked whether ZSTD_decompressStream()
returned an error.  However, a positive return value at end-of-input
means that the final zstd frame has not completed.  Record the state
and verify at finalization that zstd completed the frame.  Also flush
any pending internally buffered output before performing that check.

astreamer_gzip_decompressor did not check whether inflate() had
reached Z_STREAM_END before finalizing.  Record whether inflate()
completed the gzip stream, and reject finalization if it did not.

astreamer_lz4_decompressor did not check whether LZ4F_decompress()
completed the final frame before finalizing.  Record the status of
decompression and reject finalization unless the frame completed.

This prevents pg_verifybackup from accepting a truncated compressed
tar backup.

Author: Chao Li <lic@highgo.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/5962B878-C43D-4EBC-9E95-1F945CE5E586@gmail.com
Backpatch-through: 19

Branch
------
master

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

Modified Files
--------------
src/bin/pg_verifybackup/t/010_client_untar.pl | 13 ++++++++
src/fe_utils/astreamer_gzip.c                 | 13 +++++++-
src/fe_utils/astreamer_lz4.c                  | 13 ++++++++
src/fe_utils/astreamer_zstd.c                 | 46 +++++++++++++++++++++++++++
src/include/fe_utils/astreamer.h              | 14 ++++++++
src/tools/pgindent/typedefs.list              |  1 +
6 files changed, 99 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix detection of truncated compressed backups
@ 2026-10-09 11:43  Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Daniel Gustafsson @ 2026-10-09 11:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix detection of truncated compressed backups

pg_verifybackup failed to detect truncated compressed tar backups
for zstd, lz4 and gzip compression.

astreamer_zstd_decompressor checked whether ZSTD_decompressStream()
returned an error.  However, a positive return value at end-of-input
means that the final zstd frame has not completed.  Record the state
and verify at finalization that zstd completed the frame.  Also flush
any pending internally buffered output before performing that check.

astreamer_gzip_decompressor did not check whether inflate() had
reached Z_STREAM_END before finalizing.  Record whether inflate()
completed the gzip stream, and reject finalization if it did not.

astreamer_lz4_decompressor did not check whether LZ4F_decompress()
completed the final frame before finalizing.  Record the status of
decompression and reject finalization unless the frame completed.

This prevents pg_verifybackup from accepting a truncated compressed
tar backup.

Author: Chao Li <lic@highgo.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/5962B878-C43D-4EBC-9E95-1F945CE5E586@gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2566e51f47bb7020f170ac2ef228612227085b2d

Modified Files
--------------
src/bin/pg_verifybackup/t/010_client_untar.pl | 13 ++++++++
src/fe_utils/astreamer_gzip.c                 | 13 +++++++-
src/fe_utils/astreamer_lz4.c                  | 13 ++++++++
src/fe_utils/astreamer_zstd.c                 | 46 +++++++++++++++++++++++++++
src/include/fe_utils/astreamer.h              | 14 ++++++++
src/tools/pgindent/typedefs.list              |  1 +
6 files changed, 99 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-09 11:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09 11:43 pgsql: Fix detection of truncated compressed backups Daniel Gustafsson <dgustafsson@postgresql.org>
2026-10-09 11:43 pgsql: Fix detection of truncated compressed backups Daniel Gustafsson <dgustafsson@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox