From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 6/7] oss-fuzz: handle reftable iterator initialization failures
Date: Thu, 17 Sep 2026 17:52:35 +0000 [thread overview]
Message-ID: <de28e72d5f5e3fe59666919510242daf82845337.1789667556.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2231.git.1789667556.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
The reftable fuzzer introduced by adf45165e65b (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>
---
oss-fuzz/fuzz-reftable.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/oss-fuzz/fuzz-reftable.c b/oss-fuzz/fuzz-reftable.c
index c46eac2c6b..75b8ad0c3d 100644
--- a/oss-fuzz/fuzz-reftable.c
+++ b/oss-fuzz/fuzz-reftable.c
@@ -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);
--
gitgitgadget
next prev parent reply other threads:[~2026-09-17 17:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 17:52 [PATCH 0/7] Fix issues pointed out in Git for Windows by Coverity after merging v2.56.0-rc0 Johannes Schindelin via GitGitGadget
2026-09-17 17:52 ` [PATCH 1/7] wrapper: guard writev_in_full() against signed overflow Johannes Schindelin via GitGitGadget
2026-09-17 17:52 ` [PATCH 2/7] gpg-interface: make signature-prefix matching length-aware Johannes Schindelin via GitGitGadget
2026-09-17 19:32 ` Junio C Hamano
2026-09-18 7:12 ` Johannes Schindelin
2026-09-18 8:59 ` Junio C Hamano
2026-09-17 17:52 ` [PATCH 3/7] midx: validate incremental MIDX pack IDs Johannes Schindelin via GitGitGadget
2026-09-17 17:52 ` [PATCH 4/7] rerere: do not record failed conflict resolution data Johannes Schindelin via GitGitGadget
2026-09-17 19:34 ` Junio C Hamano
2026-09-17 17:52 ` [PATCH 5/7] t/unit-tests: check reftable iterator initialization Johannes Schindelin via GitGitGadget
2026-09-17 17:52 ` Johannes Schindelin via GitGitGadget [this message]
2026-09-17 17:52 ` [PATCH 7/7] test-read-midx: check midx_fill_entry() result Johannes Schindelin via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de28e72d5f5e3fe59666919510242daf82845337.1789667556.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox