[Python-checkins] cpython (merge 3.3 -> default): merge 3.3

benjamin.peterson python-checkins at python.org
Fri Jan 18 06:13:00 CET 2013


http://hg.python.org/cpython/rev/e6cd37d4dad8
changeset:   81569:e6cd37d4dad8
parent:      81567:cb297930d2cf
parent:      81568:2adc83b4738f
user:        Benjamin Peterson <benjamin at python.org>
date:        Fri Jan 18 00:10:37 2013 -0500
summary:
  merge 3.3

files:
  Lib/test/test_signal.py |  11 +++++++++--
  Misc/NEWS               |   3 +++
  Modules/signalmodule.c  |   2 +-
  3 files changed, 13 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
@@ -219,6 +219,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):
     def check_wakeup(self, test_body, *signals, ordered=True):
@@ -861,8 +868,8 @@
 def test_main():
     try:
         support.run_unittest(PosixTests, InterProcessSignalTests,
-                             WakeupSignalTests, SiginterruptTest,
-                             ItimerTest, WindowsSignalTests,
+                             WakeupFDTests, WakeupSignalTests,
+                             SiginterruptTest, ItimerTest, WindowsSignalTests,
                              PendingSignalsTests)
     finally:
         support.reap_children()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -220,6 +220,9 @@
 Library
 -------
 
+- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file
+  descriptor argument.
+
 - Issue #16422: For compatibility with the Python version, the C version of
   decimal now uses strings instead of integers for rounding mode constants.
 
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -422,7 +422,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