cpython: 87bbe810e4e7 (original) (raw)

Mercurial > cpython

changeset 87954:87bbe810e4e7 3.3

Issue #17919: Fixed integer overflow in the eventmask parameter. [#17919]

Serhiy Storchaka storchaka@gmail.com
date Sat, 14 Dec 2013 19:12:02 +0200
parents b9a7b2973dd6
children 2fbb3c77f157 35f6a5937a63
files Lib/test/test_devpoll.py Lib/test/test_poll.py Misc/NEWS Modules/selectmodule.c
diffstat 4 files changed, 50 insertions(+), 17 deletions(-)[+] [-] Lib/test/test_devpoll.py 11 Lib/test/test_poll.py 13 Misc/NEWS 3 Modules/selectmodule.c 40

line wrap: on

line diff

--- a/Lib/test/test_devpoll.py +++ b/Lib/test/test_devpoll.py @@ -87,6 +87,17 @@ class DevPollTests(unittest.TestCase): self.assertRaises(OverflowError, pollster.poll, 1 << 63) self.assertRaises(OverflowError, pollster.poll, 1 << 64)

+ + def test_main(): run_unittest(DevPollTests)

--- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -3,7 +3,7 @@ import os import random import select -import _testcapi +from _testcapi import USHRT_MAX, INT_MAX, UINT_MAX try: import threading except ImportError: @@ -159,10 +159,13 @@ class PollTests(unittest.TestCase): if x != 5: self.fail('Overflow must have occurred')

@unittest.skipUnless(threading, 'Threading required for this test.') @reap_threads

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -32,7 +32,8 @@ Core and Builtins Library ------- -- Issue #17919: select.poll.poll() again works with poll.POLLNVAL on AIX. +- Issue #17919: select.poll.register() again works with poll.POLLNVAL on AIX.

--- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -361,7 +361,7 @@ update_ufd_array(pollObject self) assert(i < self->ufd_len); / Never overflow */ self->ufds[i].fd = (int)PyLong_AsLong(key);

+

+

+} + PyDoc_STRVAR(poll_register_doc, "register(fd [, eventmask] ) -> None\n\n[](#l4.35) Register a file descriptor with the polling object.\n[](#l4.36) @@ -380,12 +398,12 @@ static PyObject * poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value;

fd = PyObject_AsFileDescriptor(o); if (fd == -1) return NULL; @@ -423,12 +441,12 @@ static PyObject * poll_modify(pollObject *self, PyObject *args) { PyObject *o, *key, *value;

fd = PyObject_AsFileDescriptor(o); if (fd == -1) return NULL; @@ -726,11 +744,11 @@ static PyObject * internal_devpoll_register(devpollObject *self, PyObject *args, int remove) { PyObject *o;

fd = PyObject_AsFileDescriptor(o); if (fd == -1) return NULL; @@ -746,7 +764,7 @@ internal_devpoll_register(devpollObject } self->fds[self->n_fds].fd = fd;

if (++self->n_fds == self->max_n_fds) { if (devpoll_flush(self))