Skip to content

Commit af0cd93

Browse files
committed
Fix "OSError: [Errno 36] File name too long" in fuzz_submodule
Fixes a bug in the `fuzz_submodule` harness where the fuzzed data can produce file names that exceed the maximum size allowed byt the OS. This issue came up previously and was fixed in gitpython-developers#1922, but the submodule file name fixed here was missed in that PR. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69456
1 parent 855befa commit af0cd93

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fuzzing/fuzz-targets/fuzz_submodule.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ def TestOneInput(data):
3535
sub_repo = Repo.init(submodule_temp_dir, bare=fdp.ConsumeBool())
3636
sub_repo.index.commit(fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 512)))
3737

38-
submodule_name = f"submodule_{fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 512))}"
38+
submodule_name = fdp.ConsumeUnicodeNoSurrogates(
39+
fdp.ConsumeIntInRange(1, max(1, get_max_filename_length(repo.working_tree_dir)))
40+
)
3941
submodule_path = os.path.join(repo.working_tree_dir, submodule_name)
40-
submodule_url = sub_repo.git_dir
4142

42-
submodule = repo.create_submodule(submodule_name, submodule_path, url=submodule_url)
43-
repo.index.commit(f"Added submodule {submodule_name}")
43+
submodule = repo.create_submodule(submodule_name, submodule_path, url=sub_repo.git_dir)
44+
repo.index.commit("Added submodule")
4445

4546
with submodule.config_writer() as writer:
4647
key_length = fdp.ConsumeIntInRange(1, max(1, fdp.remaining_bytes()))

0 commit comments

Comments
 (0)