git/reftable
Johannes Schindelin ae1ca21ac3 reftable/block: check deflateInit() return value
block_writer_init() allocates a z_stream and calls deflateInit()
to prepare it for compressing log records. The return value of
deflateInit() is silently discarded. If zlib initialization fails
(e.g., Z_MEM_ERROR when the system is under memory pressure), the
z_stream is left in an undefined state.

Subsequent deflate() calls in block_writer_finish() then operate
on this uninitialized stream. Depending on the zlib
implementation, this can produce silently corrupted compressed
data (which would be written to the reftable file and discovered
only when a later reader fails to inflate) or crash outright.

The function already uses REFTABLE_ZLIB_ERROR for deflate()
failures later in the code path (lines 171, 199), so returning
the same error code for deflateInit() failure is consistent.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-14 18:02:00 -07:00
..
LICENSE
basics.c reftable: check for trailing newline in 'tables.list' 2025-10-07 09:22:57 -07:00
basics.h reftable: check for trailing newline in 'tables.list' 2025-10-07 09:22:57 -07:00
block.c reftable/block: check deflateInit() return value 2026-07-14 18:02:00 -07:00
block.h Merge branch 'ps/reftable-api-revamp' 2025-04-29 14:21:30 -07:00
blocksource.c reftable/system: add abstraction to mmap files 2026-04-02 10:45:44 -07:00
blocksource.h reftable/block: rename `block` to `block_data` 2025-04-07 14:53:10 -07:00
constants.h reftable/constants: make block types part of the public interface 2025-04-07 14:53:12 -07:00
error.c reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
fsck.c reftable/fsck: use REFTABLE_UNUSED instead of UNUSED 2026-04-02 10:45:43 -07:00
iter.c reftable/constants: make block types part of the public interface 2025-04-07 14:53:12 -07:00
iter.h reftable/block: rename `block_reader` to `reftable_block` 2025-04-07 14:53:10 -07:00
merged.c reftable/constants: make block types part of the public interface 2025-04-07 14:53:12 -07:00
merged.h reftable/reader: rename data structure to "table" 2025-04-07 14:53:09 -07:00
pq.c reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
pq.h reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
record.c Merge branch 'ps/reftable-api-revamp' 2025-04-29 14:21:30 -07:00
record.h reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
reftable-basics.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-block.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-blocksource.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-constants.h reftable/constants: make block types part of the public interface 2025-04-07 14:53:12 -07:00
reftable-error.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-fsck.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-iterator.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-merged.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-record.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-stack.h reftable: split up write options 2026-06-26 08:27:19 -07:00
reftable-system.h reftable/stack: provide fsync(3p) via system header 2026-04-02 10:45:43 -07:00
reftable-table.h reftable: introduce "reftable-system.h" header 2026-04-02 10:45:43 -07:00
reftable-writer.h reftable: split up write options 2026-06-26 08:27:19 -07:00
stack.c reftable: split up write options 2026-06-26 08:27:19 -07:00
stack.h reftable: split up write options 2026-06-26 08:27:19 -07:00
system.c reftable/system: add abstraction to mmap files 2026-04-02 10:45:44 -07:00
system.h doc: fix typos via codespell 2026-06-08 00:21:35 +09:00
table.c reftable: fix perf regression when reading blocks of unwanted type 2025-05-12 10:55:24 -07:00
table.h reftable/table: add `reftable_table` to the public interface 2025-04-07 14:53:12 -07:00
tree.c reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
tree.h reftable: fix formatting of the license header 2025-04-07 14:53:09 -07:00
writer.c Merge branch 'jk/reftable-leakfix' 2026-07-13 08:27:26 -07:00
writer.h reftable: split up write options 2026-06-26 08:27:19 -07:00