Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/oss-fuzz/fuzz-reftable.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / oss-fuzz / fuzz-reftable.c` 76 lines ยท 1888 bytes Raw Blame History 1 #include "git-compat-util.h" 2 #include "reftable/basics.h" 3 #include "reftable/blocksource.h" 4 #include "reftable/reftable-blocksource.h" 5 #include "reftable/reftable-error.h" 6 #include "reftable/reftable-iterator.h" 7 #include "reftable/reftable-record.h" 8 #include "reftable/reftable-table.h" 9 #include "reftable/reftable-writer.h" 10 11 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); 12 13 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 14 { 15 struct reftable_block_source source = { 0 }; 16 struct reftable_buf buf = REFTABLE_BUF_INIT; 17 struct reftable_table *table = NULL; 18 int err; 19 20 if (reftable_buf_add(&buf, (const char *)data, size) < 0) 21 goto out; 22 block_source_from_buf(&source, &buf); 23 24 err = reftable_table_new(&table, &source, "fuzz-input"); 25 if (err < 0) 26 goto out; 27 28 /* 29 * Exercise the ref, log and raw block iterators so that we cover as 30 * much of the parsing code as possible. 31 */ 32 { 33 struct reftable_ref_record ref = { 0 }; 34 struct reftable_iterator it = { 0 }; 35 36 if (!reftable_table_init_ref_iterator(table, &it)) { 37 if (!reftable_iterator_seek_ref(&it, "")) 38 while (!reftable_iterator_next_ref(&it, &ref)) 39 ; 40 } 41 42 reftable_ref_record_release(&ref); 43 reftable_iterator_destroy(&it); 44 } 45 46 { 47 struct reftable_log_record log = { 0 }; 48 struct reftable_iterator it = { 0 }; 49 50 if (!reftable_table_init_log_iterator(table, &it)) { 51 if (!reftable_iterator_seek_log(&it, "")) 52 while (!reftable_iterator_next_log(&it, &log)) 53 ; 54 } 55 56 reftable_log_record_release(&log); 57 reftable_iterator_destroy(&it); 58 } 59 60 { 61 struct reftable_table_iterator it = { 0 }; 62 const struct reftable_block *block; 63 64 if (!reftable_table_iterator_init(&it, table)) 65 while (!reftable_table_iterator_next(&it, &block)) 66 ; 67 68 reftable_table_iterator_release(&it); 69 } 70 71 out: 72 if (table) 73 reftable_table_decref(table); 74 reftable_buf_release(&buf); 75 return 0; 76 }