Skip to content

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

Closed

Description

@larryhastings
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']

    Activity

    1. larryhastings commented on Apr 13, 2015

      @larryhastings
      ContributorAuthor

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

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Apr 13, 2015
    3. serhiy-storchaka commented on Jul 11, 2018

      @serhiy-storchaka
      Member

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

    4. serhiy-storchaka commented on Jul 11, 2018

      @serhiy-storchaka
      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

    5. miss-islington commented on Jul 11, 2018

      @miss-islington
      Contributor

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

    6. miss-islington commented on Jul 11, 2018

      @miss-islington
      Contributor

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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.7 (EOL)end of life3.8 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions