From 68d0a9958d6bdd07b36cb6761bcc44a6bc1580e5 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Sat, 12 Sep 2026 10:40:24 +0200 Subject: [PATCH 1/2] peach_fuzzer: Add missing escape characters Signed-off-by: Robert Baldyga --- test_tools/peach_fuzzer/peach_fuzzer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_tools/peach_fuzzer/peach_fuzzer.py b/test_tools/peach_fuzzer/peach_fuzzer.py index eca4a78..d55350d 100644 --- a/test_tools/peach_fuzzer/peach_fuzzer.py +++ b/test_tools/peach_fuzzer/peach_fuzzer.py @@ -38,7 +38,7 @@ class PeachFuzzer: fuzzy_output_file = posixpath.join(base_dir, "fuzzedParams.txt") tested_param_placeholder = b"{param}" # escape backslash first, so it doesn't interfere with escaping other characters - escape_chars = '\\\n"\'&|;()`<>$! ' + escape_chars = '\\\n\t"\'&|;()`<>$!*#~ ' @classmethod def get_fuzzed_command(cls, command_template: str, count: int): From fd4bf35fd54b246914c44a017fe8f46a55e3d6cb Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Sat, 12 Sep 2026 10:43:44 +0200 Subject: [PATCH 2/2] peach_fuzzer: Special case new line character A backslash followed by a newline is a line continuation, so the shell removes both characters instead of passing the newline. The newline has to be quoted instead. Quotes may be embedded in the middle of a word, so the fuzzed value is still passed as a single argument. Signed-off-by: Robert Baldyga --- test_tools/peach_fuzzer/peach_fuzzer.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test_tools/peach_fuzzer/peach_fuzzer.py b/test_tools/peach_fuzzer/peach_fuzzer.py index d55350d..98beb5f 100644 --- a/test_tools/peach_fuzzer/peach_fuzzer.py +++ b/test_tools/peach_fuzzer/peach_fuzzer.py @@ -191,11 +191,17 @@ def _escape_special_chars(cls, fuzzed_str: bytes): Escaping is done for example in order to make fuzzed string executable in Linux CLI If fuzzed string will be used in other places, escape_chars list may be overwritten. """ - for i in cls.escape_chars: - i = bytes(i, "utf-8") - if i in fuzzed_str[:]: - fuzzed_str = fuzzed_str.replace(i, b'\\' + i) - return fuzzed_str + escape_bytes = set(cls.escape_chars.encode("utf-8")) + escaped = bytearray() + for char in fuzzed_str: + if char not in escape_bytes: + escaped.append(char) + elif char == ord("\n"): + escaped += b"'\n'" + else: + escaped.append(ord("\\")) + escaped.append(char) + return bytes(escaped) @classmethod def _is_xml_config_prepared(cls):