Movatterモバイル変換


[0]ホーム

URL:


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

Commit2493c3a

Browse files
authored
Merge pull request#1911 from DaveLak/add-blob-fuzz-target
Add git.Blob Fuzz Target
2 parents5f26779 +6823e45 commit2493c3a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

‎fuzzing/dictionaries/fuzz_blob.dict

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"\\377\\377\\377\\377\\377\\377\\377\\377"

‎fuzzing/fuzz-targets/fuzz_blob.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
importatheris
2+
importsys
3+
importos
4+
importtempfile
5+
6+
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
7+
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
8+
os.environ["GIT_PYTHON_GIT_EXECUTABLE"]=path_to_bundled_git_binary
9+
10+
withatheris.instrument_imports():
11+
importgit
12+
13+
14+
defTestOneInput(data):
15+
fdp=atheris.FuzzedDataProvider(data)
16+
17+
withtempfile.TemporaryDirectory()astemp_dir:
18+
repo=git.Repo.init(path=temp_dir)
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+
exceptAssertionErrorase:
26+
if"Require 20 byte binary sha, got"instr(e):
27+
return-1
28+
else:
29+
raisee
30+
31+
_=blob.mime_type
32+
33+
34+
defmain():
35+
atheris.Setup(sys.argv,TestOneInput)
36+
atheris.Fuzz()
37+
38+
39+
if__name__=="__main__":
40+
main()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp