summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2021-05-12 23:22:18 (GMT)
committerGitHub <noreply@github.com>2021-05-12 23:22:18 (GMT)
commita0ccc404ca649c2a1635511a09df2454e47b4d66 (patch)
tree0efaa369bdcff18d469ab6f87dc5083b75f03d6d /Modules
parent6cd0446ef72c6676b292d7f54b1ddb8ae5e1fb8d (diff)
downloadcpython-a0ccc404ca649c2a1635511a09df2454e47b4d66.zip
cpython-a0ccc404ca649c2a1635511a09df2454e47b4d66.tar.gz
cpython-a0ccc404ca649c2a1635511a09df2454e47b4d66.tar.bz2
bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName (GH-26083)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_xxtestfuzz/fuzzer.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c
index acbf068..e1256f5 100644
--- a/Modules/_xxtestfuzz/fuzzer.c
+++ b/Modules/_xxtestfuzz/fuzzer.c
@@ -411,9 +411,26 @@ int __lsan_is_turned_off(void) { return 1; }
int LLVMFuzzerInitialize(int *argc, char ***argv) {
- wchar_t* wide_program_name = Py_DecodeLocale(*argv[0], NULL);
- Py_SetProgramName(wide_program_name);
+ PyConfig config;
+ PyConfig_InitPythonConfig(&config);
+ config.install_signal_handlers = 0;
+ PyStatus status;
+ status = PyConfig_SetBytesString(&config, &config.program_name, *argv[0]);
+ if (PyStatus_Exception(status)) {
+ goto fail;
+ }
+
+ status = Py_InitializeFromConfig(&config);
+ if (PyStatus_Exception(status)) {
+ goto fail;
+ }
+ PyConfig_Clear(&config);
+
return 0;
+
+fail:
+ PyConfig_Clear(&config);
+ Py_ExitStatusException(status);
}
/* Fuzz test interface.
@@ -424,12 +441,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
(And we bitwise or when running multiple tests to verify that normally we
only return 0.) */
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- if (!Py_IsInitialized()) {
- /* LLVMFuzzerTestOneInput is called repeatedly from the same process,
- with no separate initialization phase, sadly, so we need to
- initialize CPython ourselves on the first run. */
- Py_InitializeEx(0);
- }
+ assert(Py_IsInitialized());
int rv = 0;