Issue #23804: Fix SSL recv/read(0) to not return 1024 bytes

This commit is contained in:
Martin Panter 2016-03-28 00:22:09 +00:00
parent ce913877e4
commit f6b1d66a3c
4 changed files with 15 additions and 5 deletions

View file

@ -2792,13 +2792,20 @@ else:
# consume data
s.read()
# read(-1, buffer) is supported, even though read(-1) is not
data = b"data"
# read(-1, buffer) is supported, even though read(-1) is not
s.send(data)
buffer = bytearray(len(data))
self.assertEqual(s.read(-1, buffer), len(data))
self.assertEqual(buffer, data)
# recv/read(0) should return no data
s.send(data)
self.assertEqual(s.recv(0), b"")
self.assertEqual(s.read(0), b"")
self.assertEqual(s.read(), data)
# Make sure sendmsg et al are disallowed to avoid
# inadvertent disclosure of data and/or corruption
# of the encrypted data stream