summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index a2c047d..626a077 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -5969,6 +5969,24 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
with self.assertRaises(TypeError):
sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
+ def test_length_restriction(self):
+ # bpo-35050, off-by-one error in length check
+ sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
+ self.addCleanup(sock.close)
+
+ # salg_type[14]
+ with self.assertRaises(FileNotFoundError):
+ sock.bind(("t" * 13, "name"))
+ with self.assertRaisesRegex(ValueError, "type too long"):
+ sock.bind(("t" * 14, "name"))
+
+ # salg_name[64]
+ with self.assertRaises(FileNotFoundError):
+ sock.bind(("type", "n" * 63))
+ with self.assertRaisesRegex(ValueError, "name too long"):
+ sock.bind(("type", "n" * 64))
+
+
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
class TestMSWindowsTCPFlags(unittest.TestCase):
knownTCPFlags = {