pgsql: Fix yet another bug in archive streamer with LZ4 decompression.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix yet another bug in archive streamer with LZ4 decompression.
Date: 2026-03-04 17:08:50
Message-ID: E1vxpiM-002O4h-35@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix yet another bug in archive streamer with LZ4 decompression.

The code path in astreamer_lz4_decompressor_content() that updated
the output pointers when the output buffer isn't full was wrong.
It advanced next_out by bytes_written, which could include previous
decompression output not just that of the current cycle. The
correct amount to advance is out_size. While at it, make the
output pointer updates look more like the input pointer updates.

This bug is pretty hard to reach, as it requires consecutive
compression frames that are too small to fill the output buffer.
pg_dump could have produced such data before 66ec01dc4, but
I'm unsure whether any files we use astreamer with would be
likely to contain problematic data.

Author: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/0594CC79-1544-45DD-8AA4-26270DE777A7@gmail.com
Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/78dc9a808201b06a59f2bfb03018f790a5fc15ba

Modified Files
--------------
src/fe_utils/astreamer_lz4.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-03-04 17:08:51 pgsql: Fix yet another bug in archive streamer with LZ4 decompression.
Previous Message Jacob Champion 2026-03-04 17:01:06 Re: pgsql: Change default value of default_toast_compression to "lz4", when