Repository navigation
getargs.c skipitem() doesn't skip 'w*' #68115
Copy link
Copy link
Closed
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/larryhastings'
closed_at = <Date 2018-07-23.19:38:55.308>
created_at = <Date 2015-04-13.02:44:28.359>
labels = ['interpreter-core', '3.7', '3.8', 'type-crash']
title = "getargs.c skipitem() doesn't skip 'w*'"
updated_at = <Date 2018-07-23.19:38:55.307>
user = 'https://github.com/larryhastings'bugs.python.org fields:
activity = <Date 2018-07-23.19:38:55.307>
actor = 'serhiy.storchaka'
assignee = 'larry'
closed = True
closed_date = <Date 2018-07-23.19:38:55.308>
closer = 'serhiy.storchaka'
components = ['Interpreter Core']
creation = <Date 2015-04-13.02:44:28.359>
creator = 'larry'
dependencies = []
files = []
hgrepos = []
issue_num = 23927
keywords = ['patch']
message_count = 5.0
messages = ['240588', '321465', '321485', '321486', '321489']
nosy_count = 3.0
nosy_names = ['larry', 'serhiy.storchaka', 'miss-islington']
pr_nums = ['8192', '8251', '8252', '8255', '8204']
priority = 'low'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue23927'
versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
larryhastings commentedon Apr 13, 2015
tl;dr: skipitem() in Python/getsargs.c doesn't know about the 'w*' format unit, which could lead to a crash. It should know about it.
--
If:
PyArg_ParseTupleAndKeywords (or its cousins),
CPython will call skipitem() to skip over the remaining positional parameters so it can process keyword arguments. It does this by knowing all the format units, and iterating over them and throwing away the various varargs pointers until it hits the keyword arguments part of the format string.
Since nobody ever explained about the "w*" format unit to it, that means when it sees 'w*' it will misinterpret it.
In both 2.7 and 3.x, it'll interpret it as 'w', throw away one "char *" item from varargs, then the next thing that tries to parse a format unit (skipitem or convertsimple) will see the '*' and throw an 'impossible<bad format char>' exception.
(It's another bug that skipitem() supports 'w' and 'w#' in Python 3, but I filed that separately as bpo-23926 .)
serhiy-storchaka commentedon Jul 11, 2018
New changeset 504373c by Serhiy Storchaka in branch 'master':
bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
504373c
serhiy-storchaka commentedon Jul 11, 2018
New changeset ef19fd2 by Serhiy Storchaka in branch '2.7':
[2.7] bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192). (GH-8255)
ef19fd2
miss-islington commentedon Jul 11, 2018
New changeset 48d2aeb by Miss Islington (bot) in branch '3.7':
bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
48d2aeb
miss-islington commentedon Jul 11, 2018
New changeset ec75620 by Miss Islington (bot) in branch '3.6':
bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
ec75620