Skip to content

Commit 6823e45

Browse files
committed
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.
1 parent 48abb1c commit 6823e45

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fuzzing/fuzz-targets/fuzz_blob.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ def TestOneInput(data):
1616

1717
with tempfile.TemporaryDirectory() as temp_dir:
1818
repo = git.Repo.init(path=temp_dir)
19-
blob = git.Blob(
20-
repo,
21-
**{
22-
"binsha": git.Blob.NULL_BIN_SHA,
23-
"path": fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes()),
24-
},
25-
)
19+
binsha = fdp.ConsumeBytes(20)
20+
mode = fdp.ConsumeInt(fdp.ConsumeIntInRange(0, fdp.remaining_bytes()))
21+
path = fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes())
22+
23+
try:
24+
blob = git.Blob(repo, binsha, mode, path)
25+
except AssertionError as e:
26+
if "Require 20 byte binary sha, got" in str(e):
27+
return -1
28+
else:
29+
raise e
2630

2731
_ = blob.mime_type
2832

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy