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

Commitdac3535

Browse files
committed
Attempt 2 - Fix Missing Git Executable Causing ClusterFuzz Crash
This is a second attempt at#1906 and should resolve:-#1905-google/oss-fuzz#10600PR#1906 had the right idea but wrong implementation, and the differences betweenthe ClusterFuzz image that it was supposed to fix and the OSS-Fuzz image wherethe fix was tested led to the issue not being fully resolved.The root cause of the issue is the same: A Git executable is not globallyavailable in the ClusterFuzz container environment where OSS-Fuzz executesfuzz tests.#1906 attempted to fix the issue by bundling the Git binary and usingGitPython's `git.refresh(<full-path-to-git-executable>)` method to set itinside the `TestOneInput` function of the test harness.However, GitPython attempts to set the binary at import time via its `__init__`hook, and crashes the test if no executable is found during the import.This issue is fixed here by setting the environment variable that GitPythonlooks in before importing it, so it's available for the import. This was testedby setting the `$PATH` to an empty string inside the test files, whichreproduced the crash, then adding the changes introduced here with `$PATH` stillempty, which avoided the crash indicating that the bundled Git executable isworking as expected.
1 parent82bb3bb commitdac3535

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎fuzzing/fuzz-targets/fuzz_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
importos
2424
fromconfigparserimportMissingSectionHeaderError,ParsingError
2525

26+
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
27+
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
28+
os.environ["GIT_PYTHON_GIT_EXECUTABLE"]=path_to_bundled_git_binary
29+
2630
withatheris.instrument_imports():
2731
importgit
2832

2933

3034
defTestOneInput(data):
31-
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
32-
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
33-
git.refresh(path_to_bundled_git_binary)
34-
3535
sio=io.BytesIO(data)
3636
sio.name="/tmp/fuzzconfig.config"
3737
git_config=git.GitConfigParser(sio)

‎fuzzing/fuzz-targets/fuzz_tree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
importos
2424
importshutil
2525

26+
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
27+
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
28+
os.environ["GIT_PYTHON_GIT_EXECUTABLE"]=path_to_bundled_git_binary
29+
2630
withatheris.instrument_imports():
2731
importgit
2832

2933

3034
defTestOneInput(data):
31-
ifgetattr(sys,"frozen",False)andhasattr(sys,"_MEIPASS"):
32-
path_to_bundled_git_binary=os.path.abspath(os.path.join(os.path.dirname(__file__),"git"))
33-
git.refresh(path_to_bundled_git_binary)
34-
3535
fdp=atheris.FuzzedDataProvider(data)
3636
git_dir="/tmp/.git"
3737
head_file=os.path.join(git_dir,"HEAD")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp