mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName (GH-26083)
This commit is contained in:
parent
6cd0446ef7
commit
a0ccc404ca
1 changed files with 20 additions and 8 deletions
|
@ -411,9 +411,26 @@ int __lsan_is_turned_off(void) { return 1; }
|
||||||
|
|
||||||
|
|
||||||
int LLVMFuzzerInitialize(int *argc, char ***argv) {
|
int LLVMFuzzerInitialize(int *argc, char ***argv) {
|
||||||
wchar_t* wide_program_name = Py_DecodeLocale(*argv[0], NULL);
|
PyConfig config;
|
||||||
Py_SetProgramName(wide_program_name);
|
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;
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
PyConfig_Clear(&config);
|
||||||
|
Py_ExitStatusException(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fuzz test interface.
|
/* 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
|
(And we bitwise or when running multiple tests to verify that normally we
|
||||||
only return 0.) */
|
only return 0.) */
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
if (!Py_IsInitialized()) {
|
assert(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue