path: root/packfile.h
diff options
authorJosh Steadmon <>2018-10-13 00:58:41 (GMT)
committerJunio C Hamano <>2018-10-15 05:29:03 (GMT)
commit1127a98ccea2a911d2043dcc9ce301e080a3cc39 (patch)
treee22ba4d30cc39102180641508bdff90b9fef76dd /packfile.h
parent5e47215080018b7eea2054ec70f5d686715d66ee (diff)
fuzz: add fuzz testing for packfile indices.
Breaks the majority of check_packed_git_idx() into a separate function, load_idx(). The latter function operates on arbitrary buffers, which makes it suitable as a fuzzing test target. Signed-off-by: Josh Steadmon <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'packfile.h')
1 files changed, 13 insertions, 0 deletions
diff --git a/packfile.h b/packfile.h
index 4426257..6c40376 100644
--- a/packfile.h
+++ b/packfile.h
@@ -164,4 +164,17 @@ extern int has_pack_index(const unsigned char *sha1);
extern int is_promisor_object(const struct object_id *oid);
+ * Expose a function for fuzz testing.
+ *
+ * load_idx() parses a block of memory as a packfile index and puts the results
+ * into a struct packed_git.
+ *
+ * This function should not be used directly. It is exposed here only so that we
+ * have a convenient entry-point for fuzz testing. For real uses, you should
+ * probably use open_pack_index() or parse_pack_index() instead.
+ */
+extern int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
+ size_t idx_size, struct packed_git *p);