git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/7] oss-fuzz: handle reftable iterator initialization failures

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 17, 2026, 17:52 UTC
Message-ID
<de28e72d5f5e3fe59666919510242daf82845337.1789667556.git.gitgitgadget@gmail.com>
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
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 11 of 12 in “Fix issues pointed out in Git for Windows by Coverity after merging v2.56.0-rc0”
  1. 0/7 Fix issues pointed out in Git for Windows by Coverity after merging v2.56.0-rc0Johannes Schindelin via GitGitGadget, Sep 17, 2026
  2. 1/7 wrapper: guard writev_in_full() against signed overflowJohannes Schindelin via GitGitGadget, Sep 17, 2026
  3. 2/7 gpg-interface: make signature-prefix matching length-awareJohannes Schindelin via GitGitGadget, Sep 17, 2026
  4. Junio C HamanoSep 17, 2026
  5. Johannes SchindelinSep 18, 2026
  6. Junio C HamanoSep 18, 2026
  7. 3/7 midx: validate incremental MIDX pack IDsJohannes Schindelin via GitGitGadget, Sep 17, 2026
  8. 4/7 rerere: do not record failed conflict resolution dataJohannes Schindelin via GitGitGadget, Sep 17, 2026
  9. Junio C HamanoSep 17, 2026
  10. 5/7 t/unit-tests: check reftable iterator initializationJohannes Schindelin via GitGitGadget, Sep 17, 2026
  11. 6/7 oss-fuzz: handle reftable iterator initialization failuresJohannes Schindelin via GitGitGadget, Sep 17, 2026
  12. 7/7 test-read-midx: check midx_fill_entry() resultJohannes Schindelin via GitGitGadget, Sep 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.