bpo-30058: Fixed buffer overflow in select.kqueue.control(). (#1095)

This commit is contained in:
Serhiy Storchaka 2017-10-12 22:17:46 +03:00 committed by GitHub
parent b7cbfe49e3
commit de07210077
3 changed files with 38 additions and 16 deletions

View file

@ -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)