You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bugs in _ssl object read() when a buffer is specified #49217
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=Noneclosed_at=<Date2009-10-21.21:11:07.655>created_at=<Date2009-01-17.02:36:50.798>labels= ['extension-modules', 'type-crash']
title='Bugs in _ssl object read() when a buffer is specified'updated_at=<Date2009-10-21.21:11:07.654>user='https://github.com/pitrou'
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.
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.
Activity
pitrou commentedon Jan 17, 2009
The read() method on ssl objects can take a buffer as a parameter, but
the method is buggy in this case:
supporting the buffer protocol in write mode
the current exception
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.
pitrou commentedon Feb 14, 2009
Bumping to critical since the io-c branch won't be merged before this is
solved.
benjaminp commentedon Feb 28, 2009
I'm no ssl expert either, but the patch looks fine to me.
benjaminp commentedon Feb 28, 2009
Applied the patch to py3k in r70072. Do you have a trunk backport?
pitrou commentedon Feb 28, 2009
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.
benjaminp commentedon Feb 28, 2009
Ok, will leave as is.
pitrou commentedon Oct 21, 2009
Ok, there is nothing to backport since the trunk version doesn't handle
bytearrays in the first place!