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

Appearance settings

Commit 2c8efc7

Browse filesBrowse files
committed
k
1 parent 0fcf291 commit 2c8efc7
Copy full SHA for 2c8efc7

3 files changed

+24-9Lines changed: 24 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.sonar/.sonar_lock‎

Copy file name to clipboardExpand all lines: .sonar/.sonar_lock
Whitespace-only changes.
Collapse file

‎.sonar/report-task.txt‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
projectKey=gitpython
2+
serverUrl=http://localhost:9000
3+
serverVersion=25.11.0.114957
4+
dashboardUrl=http://localhost:9000/dashboard?id=gitpython
5+
ceTaskId=2995a1e0-8d5e-4084-ab1f-43394b167529
6+
ceTaskUrl=http://localhost:9000/api/ce/task?id=2995a1e0-8d5e-4084-ab1f-43394b167529
Collapse file

‎fuzzing/fuzz-targets/fuzz_config.py‎

Copy file name to clipboardExpand all lines: fuzzing/fuzz-targets/fuzz_config.py
+18-9Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,31 @@
3030
with atheris.instrument_imports():
3131
import git
3232

33+
def handle_fuzz_exception(e):
34+
"""Handle all expected exceptions from git_config.read()."""
35+
# Expected config parsing-related errors → reject input.
36+
if isinstance(e, (MissingSectionHeaderError, ParsingError, UnicodeDecodeError)):
37+
return -1
38+
39+
# Special-case ValueError coming from embedded null bytes.
40+
if isinstance(e, ValueError):
41+
if "embedded null byte" in str(e):
42+
return -1
43+
# Any other ValueError is unexpected → re-raise.
44+
raise e
45+
46+
# Any other exception type is unexpected → re-raise.
47+
raise e
48+
3349

3450
def TestOneInput(data):
3551
sio = io.BytesIO(data)
3652
sio.name = "/tmp/fuzzconfig.config"
3753
git_config = git.GitConfigParser(sio)
3854
try:
3955
git_config.read()
40-
except (MissingSectionHeaderError, ParsingError, UnicodeDecodeError):
41-
return -1 # Reject inputs raising expected exceptions
42-
except ValueError as e:
43-
if "embedded null byte" in str(e):
44-
# The `os.path.expanduser` function, which does not accept strings
45-
# containing null bytes might raise this.
46-
return -1
47-
else:
48-
raise e # Raise unanticipated exceptions as they might be bugs
56+
except Exception as e:
57+
return handle_fuzz_exception(e)
4958

5059

5160
def main():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.