Skip to content

Commit 58d1683

Browse files
authored
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!
1 parent 941ec21 commit 58d1683

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash in Python initialization when parsing the command line options.
2+
Thanks Christoph Gohlke for the bug report and the fix!

Modules/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
761761
pymain->err = _Py_INIT_NO_MEMORY();
762762
return -1;
763763
}
764-
memcpy(command, _PyOS_optarg, len * sizeof(wchar_t));
764+
memcpy(command, _PyOS_optarg, (len - 2) * sizeof(wchar_t));
765765
command[len - 2] = '\n';
766766
command[len - 1] = 0;
767767
pymain->command = command;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy