[Python-checkins] bpo-29505: Fix interpreter in fuzzing targets to be relocatable (GH-13907)

Gregory P. Smith webhook-mailer at python.org
Sat Jun 8 10:43:20 EDT 2019

commit: a15a7bcaea54e1845ab2abe27e6f583294cd715b
branch: master
author: Ammar Askar <ammar at ammaraskar.com>
committer: Gregory P. Smith <greg at krypto.org>
date: 2019-06-08T07:43:16-07:00

bpo-29505: Fix interpreter in fuzzing targets to be relocatable (GH-13907)

M Modules/_xxtestfuzz/fuzzer.c

diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c
index b50eb6512710..54f816ebc93d 100644
--- a/Modules/_xxtestfuzz/fuzzer.c
+++ b/Modules/_xxtestfuzz/fuzzer.c
@@ -88,6 +88,14 @@ static int _run_fuzz(const uint8_t *data, size_t size, int(*fuzzer)(const char*
 /* CPython generates a lot of leak warnings for whatever reason. */
 int __lsan_is_turned_off(void) { return 1; }
+wchar_t wide_program_name[NAME_MAX];
+int LLVMFuzzerInitialize(int *argc, char ***argv) {
+    wchar_t* wide_program_name = Py_DecodeLocale(*argv[0], NULL);
+    Py_SetProgramName(wide_program_name);
+    return 0;
 /* Fuzz test interface.
    This returns the bitwise or of all fuzz test's return values.

More information about the Python-checkins mailing list