Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getargs.c skipitem() doesn't skip 'w*' #68115

Closed
larryhastings opened this issue Apr 13, 2015 · 5 comments
Closed

getargs.c skipitem() doesn't skip 'w*' #68115

larryhastings opened this issue Apr 13, 2015 · 5 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@larryhastings
Copy link
Contributor

BPO 23927
Nosy @larryhastings, @serhiy-storchaka, @miss-islington
PRs
  • bpo-23927: Make getargs.c skipitem() skipping 'w*'. #8192
  • [3.7] bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192) #8251
  • [3.6] bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192) #8252
  • [2.7] bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192). #8255
  • gh-68114: Fix handling for removed PyArg_ParseTuple formatters #8204
  • 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']

    @larryhastings
    Copy link
    Contributor Author

    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:

    • you have an extension that parses its arguments with
      PyArg_ParseTupleAndKeywords (or its cousins),
    • you have optional positional parameters, and
    • you run out of positional arguments

    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 .)

    @larryhastings larryhastings self-assigned this Apr 13, 2015
    @larryhastings larryhastings added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Apr 13, 2015
    @serhiy-storchaka
    Copy link
    Member

    New changeset 504373c by Serhiy Storchaka in branch 'master':
    bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
    504373c

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes labels Jul 11, 2018
    @serhiy-storchaka
    Copy link
    Member

    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
    Copy link
    Contributor

    New changeset 48d2aeb by Miss Islington (bot) in branch '3.7':
    bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
    48d2aeb

    @miss-islington
    Copy link
    Contributor

    New changeset ec75620 by Miss Islington (bot) in branch '3.6':
    bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)
    ec75620

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants