[Python-checkins] cpython (2.7): check windows fd validity (closes #16992)
benjamin.peterson
python-checkins at python.org
Fri Jan 18 06:13:01 CET 2013
http://hg.python.org/cpython/rev/1a1989021451
changeset: 81570:1a1989021451
branch: 2.7
parent: 81565:af5feb869304
user: Benjamin Peterson <benjamin at python.org>
date: Fri Jan 18 00:10:24 2013 -0500
summary:
check windows fd validity (closes #16992)
files:
Lib/test/test_signal.py | 12 ++++++++++--
Misc/NEWS | 3 +++
Modules/signalmodule.c | 2 +-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -227,6 +227,13 @@
signal.signal(7, handler)
+class WakeupFDTests(unittest.TestCase):
+
+ def test_invalid_fd(self):
+ fd = support.make_bad_fd()
+ self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
+
+
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class WakeupSignalTests(unittest.TestCase):
TIMEOUT_FULL = 10
@@ -485,8 +492,9 @@
def test_main():
test_support.run_unittest(BasicSignalTests, InterProcessSignalTests,
- WakeupSignalTests, SiginterruptTest,
- ItimerTest, WindowsSignalTests)
+ WakeupFDTests, WakeupSignalTests,
+ SiginterruptTest, ItimerTest,
+ WindowsSignalTests)
if __name__ == "__main__":
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -189,6 +189,9 @@
Library
-------
+- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file
+ descriptor argument.
+
- Issue #15861: tkinter now correctly works with lists and tuples containing
strings with whitespaces, backslashes or unbalanced braces.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -407,7 +407,7 @@
return NULL;
}
#endif
- if (fd != -1 && fstat(fd, &buf) != 0) {
+ if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) {
PyErr_SetString(PyExc_ValueError, "invalid fd");
return NULL;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list