diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-05-31 13:09:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 13:09:28 (GMT) |
commit | 58d1683255abb0df4fc70960da6121aeaa41e1d1 (patch) | |
tree | f2cfc80547018a700beef7b6a39d3acca9d98bbb /Modules | |
parent | 941ec210aaef517cf818b043ec28345962f78465 (diff) | |
download | cpython-58d1683255abb0df4fc70960da6121aeaa41e1d1.zip cpython-58d1683255abb0df4fc70960da6121aeaa41e1d1.tar.gz cpython-58d1683255abb0df4fc70960da6121aeaa41e1d1.tar.bz2 |
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!
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c index 9cbb3f1..286ad41 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -761,7 +761,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _Py_CommandLineDetails *cmdline) 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; |