Skip to content

Conversation

@quazam
Copy link

@quazam quazam commented Feb 9, 2021

This commit fixes a bug where a poll() for read would not consider
bytes available internally within the mbedtls_ssl's application data
record read buffer. The bug would trigger if the caller's previous
read() only retreived a portion of the bytes available, then called
poll(). In spite of the wrapped socket being immediately readable, the
poll() would incorrectly block (or timeout) because it was passing
the poll ioctl down to the raw socket and waiting for additional
encrypted data to arrive on the raw socket.

The fix checks for bytes available via the
mbedtls_ssl_get_bytes_avail() call before handing down to the raw
socket.

This commit fixes a bug where a poll() for read would not consider
bytes available internally within the mbedtls_ssl's application data
record read buffer. The bug would trigger if the caller's previous
read() only retreived a portion of the bytes available, then called
poll(). In spite of the wrapped socket being immediately readable, the
poll() would incorrectly block (or timeout) because it was passing
the poll ioctl down to the raw socket and waiting for additional
encrypted data to arrive on the raw socket.

The fix checks for bytes available via the
mbedtls_ssl_get_bytes_avail() call before handing down to the raw
socket.

Signed-off-by: Johnathan York <[email protected]>
@quazam quazam force-pushed the fix-ussl-poll-hang branch from 4342176 to ebf3522 Compare February 9, 2021 05:47
@tve tve mentioned this pull request Feb 9, 2021
@tve
Copy link
Contributor

tve commented Feb 9, 2021

Yup: #5840 , which is blocked behind #6615 ;-)

@dpgeorge
Copy link
Member

Thanks for the contribution, but I'll close this is favour of #5840.

@dpgeorge dpgeorge closed this Feb 17, 2021
@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Feb 17, 2021
Wind-stormger pushed a commit to BPI-STEAM/micropython that referenced this pull request Sep 8, 2022
…n-main

Translations update from Hosted Weblate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extmod Relates to extmod/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants