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

memcpy(NULL, NULL, 0) in array_new() #66795

Closed
jwilk mannequin opened this issue Oct 10, 2014 · 3 comments
Closed

memcpy(NULL, NULL, 0) in array_new() #66795

jwilk mannequin opened this issue Oct 10, 2014 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@jwilk
Copy link
Mannequin

jwilk mannequin commented Oct 10, 2014

BPO 22605
Nosy @jwilk
Files
  • 229023.patch
  • 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 = None
    closed_at = <Date 2014-10-11.00:58:50.265>
    created_at = <Date 2014-10-10.19:15:10.423>
    labels = ['library']
    title = 'memcpy(NULL, NULL, 0) in array_new()'
    updated_at = <Date 2014-10-11.00:58:50.224>
    user = 'https://github.com/jwilk'

    bugs.python.org fields:

    activity = <Date 2014-10-11.00:58:50.224>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-10-11.00:58:50.265>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2014-10-10.19:15:10.423>
    creator = 'jwilk'
    dependencies = []
    files = ['36871']
    hgrepos = []
    issue_num = 22605
    keywords = ['patch']
    message_count = 3.0
    messages = ['229023', '229024', '229054']
    nosy_count = 2.0
    nosy_names = ['jwilk', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue22605'
    versions = ['Python 3.5']

    @jwilk jwilk mannequin added the stdlib Python modules in the Lib dir label Oct 10, 2014
    @jwilk
    Copy link
    Mannequin Author

    jwilk mannequin commented Oct 10, 2014

    If you initialize array with another empty array, then this code runs:

    memcpy(self->ob_item, other->ob_item, len * other->ob_descr->itemsize);
    

    But self->ob_item and other->ob_item are NULL in such case.
    Passing null pointer to memcpy() is undefined behavior even when length is 0.

    @jwilk jwilk mannequin changed the title memcpy(NULL, NULL, 0) in memcpy(NULL, NULL, 0) in array_new() Oct 10, 2014
    @jwilk
    Copy link
    Mannequin Author

    jwilk mannequin commented Oct 10, 2014

    The attached patch should fix the bug.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 11, 2014

    New changeset 4563fff4e099 by Benjamin Peterson in branch '3.4':
    prevent passing NULL to memcpy (closes bpo-22605)
    https://hg.python.org/cpython/rev/4563fff4e099

    New changeset 8165e44594c2 by Benjamin Peterson in branch 'default':
    merge 3.4 (closes bpo-22605)
    https://hg.python.org/cpython/rev/8165e44594c2

    @python-dev python-dev mannequin closed this as completed Oct 11, 2014
    @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
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants