Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use fuzzed data for all git.Blob arguments
This increases the edges reached by the fuzzer, making for a more
effective test with higher coverage.
  • Loading branch information
DaveLak committed May 4, 2024
commit 6823e4543f33eb623df14a5a27c9731199de7a4f
18 changes: 11 additions & 7 deletions fuzzing/fuzz-targets/fuzz_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ def TestOneInput(data):

with tempfile.TemporaryDirectory() as temp_dir:
repo = git.Repo.init(path=temp_dir)
blob = git.Blob(
repo,
**{
"binsha": git.Blob.NULL_BIN_SHA,
"path": fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes()),
},
)
binsha = fdp.ConsumeBytes(20)
mode = fdp.ConsumeInt(fdp.ConsumeIntInRange(0, fdp.remaining_bytes()))
path = fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes())

try:
blob = git.Blob(repo, binsha, mode, path)
except AssertionError as e:
if "Require 20 byte binary sha, got" in str(e):
return -1
else:
raise e

_ = blob.mime_type

Expand Down