Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /