Skip to content

Bugs in _ssl object read() when a buffer is specified #49217

Closed

Description

@pitrou
BPO 4967
Nosy @pitrou, @giampaolo, @benjaminp
Files
  • ssl-readbuffer.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 2009-10-21.21:11:07.655>
    created_at = <Date 2009-01-17.02:36:50.798>
    labels = ['extension-modules', 'type-crash']
    title = 'Bugs in _ssl object read() when a buffer is specified'
    updated_at = <Date 2009-10-21.21:11:07.654>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2009-10-21.21:11:07.654>
    actor = 'pitrou'
    assignee = 'janssen'
    closed = True
    closed_date = <Date 2009-10-21.21:11:07.655>
    closer = 'pitrou'
    components = ['Extension Modules']
    creation = <Date 2009-01-17.02:36:50.798>
    creator = 'pitrou'
    dependencies = []
    files = ['12772']
    hgrepos = []
    issue_num = 4967
    keywords = ['patch']
    message_count = 7.0
    messages = ['79996', '82119', '82927', '82939', '82943', '82944', '94325']
    nosy_count = 4.0
    nosy_names = ['janssen', 'pitrou', 'giampaolo.rodola', 'benjamin.peterson']
    pr_nums = []
    priority = 'critical'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue4967'
    versions = ['Python 2.6', 'Python 2.7']

    Activity

    1. pitrou commented on Jan 17, 2009

      @pitrou
      MemberAuthor

      The read() method on ssl objects can take a buffer as a parameter, but
      the method is buggy in this case:

      • it only accepts bytearrays, while it should accept any object
        supporting the buffer protocol in write mode
      • when the object is not a bytearray, it returns NULL without setting
        the current exception
      • since it doesn't attempt to get a buffer export from the object, there
        is no protection and the buffer could be resized while the method
        releases the GIL, leading to a likely crash

      This patch solves all three issues. Note that I'm not able to write an
      unit test for it, because test_ssl.py is too high-level (it looks more
      like functional tests than unit tests). Also, the only reason I
      discovered this is that it made some tests fail on the io-in-C branch
      (which uses readinto() a lot). I'm a complete SSL newbie.

    2. added
      extension-modules
      type-crash
      on Jan 17, 2009
    3. pitrou commented on Feb 14, 2009

      @pitrou
      MemberAuthor

      Bumping to critical since the io-c branch won't be merged before this is
      solved.

    4. benjaminp commented on Feb 28, 2009

      @benjaminp
      Contributor

      I'm no ssl expert either, but the patch looks fine to me.

    5. benjaminp commented on Feb 28, 2009

      @benjaminp
      Contributor

      Applied the patch to py3k in r70072. Do you have a trunk backport?

    6. pitrou commented on Feb 28, 2009

      @pitrou
      MemberAuthor

      No, and since I don't how to test it out of running the io-c branch on
      test_ssl and test_poplib, I'd recommend not backporting it unless an SSL
      expert takes a look.

    7. benjaminp commented on Feb 28, 2009

      @benjaminp
      Contributor

      Ok, will leave as is.

    8. pitrou commented on Oct 21, 2009

      @pitrou
      MemberAuthor

      Ok, there is nothing to backport since the trunk version doesn't handle
      bytearrays in the first place!

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

    No one assigned

      Labels

      extension-modulestype-crash

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions