oss-fuzz: handle reftable iterator initialization failures
The reftable fuzzer introduced by adf45165e6 (oss-fuzz: add fuzzer for
parsing reftables, 2026-07-03) ignored failures from
`reftable_table_init_ref_iterator()` and
`reftable_table_init_log_iterator()`. Coverity reported that under
allocation failure, either constructor can return
`REFTABLE_OUT_OF_MEMORY_ERROR` without installing an ops table, allowing
a subsequent seek to dereference NULL.
Treat iterator initialization failure as a reason to skip the
corresponding seek and iteration while retaining safe destruction for an
uninitialized iterator.
Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
jch
parent
11ab0ca4e3
commit
237edbc58d
|
|
@ -33,10 +33,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||
struct reftable_ref_record ref = { 0 };
|
||||
struct reftable_iterator it = { 0 };
|
||||
|
||||
reftable_table_init_ref_iterator(table, &it);
|
||||
if (!reftable_iterator_seek_ref(&it, ""))
|
||||
while (!reftable_iterator_next_ref(&it, &ref))
|
||||
;
|
||||
if (!reftable_table_init_ref_iterator(table, &it)) {
|
||||
if (!reftable_iterator_seek_ref(&it, ""))
|
||||
while (!reftable_iterator_next_ref(&it, &ref))
|
||||
;
|
||||
}
|
||||
|
||||
reftable_ref_record_release(&ref);
|
||||
reftable_iterator_destroy(&it);
|
||||
|
|
@ -46,10 +47,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||
struct reftable_log_record log = { 0 };
|
||||
struct reftable_iterator it = { 0 };
|
||||
|
||||
reftable_table_init_log_iterator(table, &it);
|
||||
if (!reftable_iterator_seek_log(&it, ""))
|
||||
while (!reftable_iterator_next_log(&it, &log))
|
||||
;
|
||||
if (!reftable_table_init_log_iterator(table, &it)) {
|
||||
if (!reftable_iterator_seek_log(&it, ""))
|
||||
while (!reftable_iterator_next_log(&it, &log))
|
||||
;
|
||||
}
|
||||
|
||||
reftable_log_record_release(&log);
|
||||
reftable_iterator_destroy(&it);
|
||||
|
|
|
|||
Loading…
Reference in New Issue