mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
bpo-33706: Fix pymain_parse_cmdline_impl() (GH-7283)
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!
This commit is contained in:
parent
941ec210aa
commit
58d1683255
2 changed files with 3 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a crash in Python initialization when parsing the command line options.
|
||||||
|
Thanks Christoph Gohlke for the bug report and the fix!
|
|
@ -761,7 +761,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
|
||||||
pymain->err = _Py_INIT_NO_MEMORY();
|
pymain->err = _Py_INIT_NO_MEMORY();
|
||||||
return -1;
|
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 - 2] = '\n';
|
||||||
command[len - 1] = 0;
|
command[len - 1] = 0;
|
||||||
pymain->command = command;
|
pymain->command = command;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue