summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-03-27 05:35:19 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-03-27 05:35:19 (GMT)
commit5503d4731e822e90eea387efa37934d2df41c784 (patch)
treede55bcb02b77072ad1e4c8c78029d177652f8485 /Lib/test
parent13f0c6166ff41c0971755dcb0ab7f8205f0b32a1 (diff)
downloadcpython-5503d4731e822e90eea387efa37934d2df41c784.zip
cpython-5503d4731e822e90eea387efa37934d2df41c784.tar.gz
cpython-5503d4731e822e90eea387efa37934d2df41c784.tar.bz2
Issue #26644: Raise ValueError for negative SSLSocket.recv() and read()
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ssl.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 9a48483..8c0dd31 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -2792,6 +2792,13 @@ else:
# consume data
s.read()
+ # read(-1, buffer) is supported, even though read(-1) is not
+ data = b"data"
+ s.send(data)
+ buffer = bytearray(len(data))
+ self.assertEqual(s.read(-1, buffer), len(data))
+ self.assertEqual(buffer, data)
+
# Make sure sendmsg et al are disallowed to avoid
# inadvertent disclosure of data and/or corruption
# of the encrypted data stream
@@ -2801,6 +2808,10 @@ else:
s.recvmsg_into, bytearray(100))
s.write(b"over\n")
+
+ self.assertRaises(ValueError, s.recv, -1)
+ self.assertRaises(ValueError, s.read, -1)
+
s.close()
def test_nonblocking_send(self):