| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b684cd commit 6c00ce6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | import os | |
| 4 | 4 | import tempfile | |
| 5 | 5 | from configparser import ParsingError | |
| 6 | - from utils import is_expected_exception_message | ||
| 6 | + from utils import is_expected_exception_message, get_max_filename_length | ||
| 7 | 7 | ||
| 8 | 8 | if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): | |
| 9 | 9 | path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git")) | |
@@ -42,12 +42,12 @@ def TestOneInput(data): | |||
| 42 | 42 | writer.release() | |
| 43 | 43 | ||
| 44 | 44 | submodule.update(init=fdp.ConsumeBool(), dry_run=fdp.ConsumeBool(), force=fdp.ConsumeBool()) | |
| 45 | - | ||
| 46 | 45 | submodule_repo = submodule.module() | |
| 47 | - new_file_path = os.path.join( | ||
| 48 | - submodule_repo.working_tree_dir, | ||
| 49 | - f"new_file_{fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 512))}", | ||
| 46 | + | ||
| 47 | + new_file_name = fdp.ConsumeUnicodeNoSurrogates( | ||
| 48 | + fdp.ConsumeIntInRange(1, max(1, get_max_filename_length(submodule_repo.working_tree_dir))) | ||
| 50 | 49 | ) | |
| 50 | + new_file_path = os.path.join(submodule_repo.working_tree_dir, new_file_name) | ||
| 51 | 51 | with open(new_file_path, "wb") as new_file: | |
| 52 | 52 | new_file.write(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1, 512))) | |
| 53 | 53 | submodule_repo.index.add([new_file_path]) | |
@@ -77,14 +77,13 @@ def TestOneInput(data): | |||
| 77 | 77 | BrokenPipeError, | |
| 78 | 78 | ): | |
| 79 | 79 | return -1 | |
| 80 | - except (ValueError, OSError) as e: | ||
| 80 | + except ValueError as e: | ||
| 81 | 81 | expected_messages = [ | |
| 82 | 82 | "SHA is empty", | |
| 83 | 83 | "Reference at", | |
| 84 | 84 | "embedded null byte", | |
| 85 | 85 | "This submodule instance does not exist anymore", | |
| 86 | 86 | "cmd stdin was empty", | |
| 87 | - "File name too long", | ||
| 88 | 87 | ] | |
| 89 | 88 | if is_expected_exception_message(e, expected_messages): | |
| 90 | 89 | return -1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | import atheris # pragma: no cover | |
| 2 | + import os | ||
| 2 | 3 | from typing import List # pragma: no cover | |
| 3 | 4 | ||
| 4 | 5 | ||
@@ -20,3 +21,17 @@ def is_expected_exception_message(exception: Exception, error_message_list: List | |||
| 20 | 21 | if error.lower() in exception_message: | |
| 21 | 22 | return True | |
| 22 | 23 | return False | |
| 24 | + | ||
| 25 | + | ||
| 26 | + @atheris.instrument_func | ||
| 27 | + def get_max_filename_length(path: str) -> int: | ||
| 28 | + """ | ||
| 29 | + Get the maximum filename length for the filesystem containing the given path. | ||
| 30 | + | ||
| 31 | + Args: | ||
| 32 | + path (str): The path to check the filesystem for. | ||
| 33 | + | ||
| 34 | + Returns: | ||
| 35 | + int: The maximum filename length. | ||
| 36 | + """ | ||
| 37 | + return os.pathconf(path, "PC_NAME_MAX") | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments