Fix a crash in Python initialization when parsing the command line
options.
Fix memcpy() size parameter: previously, we read one wchar_t after
the end of _PyOS_optarg. Moreover, don't copy the trailingg NUL
character: we write it manually anyway.
Thanks Christoph Gohlke for the bug report and the fix!
(cherry picked from commit
58d1683255abb0df4fc70960da6121aeaa41e1d1)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
--- /dev/null
+Fix a crash in Python initialization when parsing the command line options.
+Thanks Christoph Gohlke for the bug report and the fix!
pymain->err = _Py_INIT_NO_MEMORY();
return -1;
}
- memcpy(command, _PyOS_optarg, len * sizeof(wchar_t));
+ memcpy(command, _PyOS_optarg, (len - 2) * sizeof(wchar_t));
command[len - 2] = '\n';
command[len - 1] = 0;
pymain->command = command;