pgsql: Fix multiple bugs in astreamer pipeline code. - Mailing list pgsql-committers

From Andrew Dunstan
Subject pgsql: Fix multiple bugs in astreamer pipeline code.
Date
Msg-id E1w6pzX-001zkx-1Y@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix multiple bugs in astreamer pipeline code.

astreamer_tar_parser_content() sent the wrong data pointer when
forwarding MEMBER_TRAILER padding to the next streamer.  After
astreamer_buffer_until() buffers the padding bytes, the 'data'
pointer has been advanced past them, but the code passed 'data'
instead of bbs_buffer.data.  This caused the downstream consumer
to receive bytes from after the padding rather than the padding
itself, and could read past the end of the input buffer.

astreamer_gzip_decompressor_content() only checked for
Z_STREAM_ERROR from inflate(), silently ignoring Z_DATA_ERROR
(corrupted data) and Z_MEM_ERROR (out of memory).  Fix by
treating any return other than Z_OK, Z_STREAM_END, and
Z_BUF_ERROR as fatal.

astreamer_gzip_decompressor_free() missed calling inflateEnd() to
release zlib's internal decompression state.

astreamer_tar_parser_free() neglected to pfree() the streamer
struct itself, leaking it.

astreamer_extractor_content() did not check the return value of
fclose() when closing an extracted file.  A deferred write error
(e.g., disk full on buffered I/O) would be silently lost.

Discussion: https://postgr.es/m/results/98c6b630-acbb-44a7-97fa-1692ce2b827c@dunslane.net

Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>

Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5095f3f4a0dc2a91d1580598a4da8790a44aa7d2

Modified Files
--------------
src/fe_utils/astreamer_file.c |  4 +++-
src/fe_utils/astreamer_gzip.c | 10 ++++++++--
src/fe_utils/astreamer_tar.c  |  4 +++-
3 files changed, 14 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Álvaro Herrera
Date:
Subject: pgsql: Sort InternalBGWorkers list alphabetically
Next
From: Tom Lane
Date:
Subject: pgsql: Doc: clarify introductory description of pg_dumpall.