summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-10-12 20:20:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-10-12 20:20:44 (GMT)
commitc923da188bc055e4f3001a6daf1caf54f2b10e40 (patch)
treea149e97942c1f48a9f846559b70ff650b6634e12 /Lib
parentf8d42ea0e4341b270f1de71b4ff40cfa18420eed (diff)
downloadcpython-c923da188bc055e4f3001a6daf1caf54f2b10e40.zip
cpython-c923da188bc055e4f3001a6daf1caf54f2b10e40.tar.gz
cpython-c923da188bc055e4f3001a6daf1caf54f2b10e40.tar.bz2
[3.6] bpo-30058: Fixed buffer overflow in select.kqueue.control(). (GH-1095) (#3973)
(cherry picked from commit de072100775cc29e6cd93a75466cecbd1086f258)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_kqueue.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py
index 9f49886..1099c75 100644
--- a/Lib/test/test_kqueue.py
+++ b/Lib/test/test_kqueue.py
@@ -208,6 +208,30 @@ class TestKQueue(unittest.TestCase):
b.close()
kq.close()
+ def test_issue30058(self):
+ # changelist must be an iterable
+ kq = select.kqueue()
+ a, b = socket.socketpair()
+ ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
+
+ kq.control([ev], 0)
+ # not a list
+ kq.control((ev,), 0)
+ # __len__ is not consistent with __iter__
+ class BadList:
+ def __len__(self):
+ return 0
+ def __iter__(self):
+ for i in range(100):
+ yield ev
+ kq.control(BadList(), 0)
+ # doesn't have __len__
+ kq.control(iter([ev]), 0)
+
+ a.close()
+ b.close()
+ kq.close()
+
def test_close(self):
open_file = open(__file__, "rb")
self.addCleanup(open_file.close)