[Python-checkins] cpython (3.2): Closes #15793: Stack corruption in ssl.RAND_egd()

jesus.cea python-checkins at python.org
Tue Sep 11 02:24:00 CEST 2012


http://hg.python.org/cpython/rev/827bb0554f1f
changeset:   78983:827bb0554f1f
branch:      3.2
parent:      78980:56a2e862561c
user:        Jesus Cea <jcea at jcea.es>
date:        Tue Sep 11 02:00:58 2012 +0200
summary:
  Closes #15793: Stack corruption in ssl.RAND_egd()

files:
  Lib/test/test_ssl.py |  8 ++------
  Misc/NEWS            |  3 +++
  Modules/_ssl.c       |  2 +-
  3 files changed, 6 insertions(+), 7 deletions(-)


diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -103,12 +103,8 @@
             sys.stdout.write("\n RAND_status is %d (%s)\n"
                              % (v, (v and "sufficient randomness") or
                                 "insufficient randomness"))
-        try:
-            ssl.RAND_egd(1)
-        except TypeError:
-            pass
-        else:
-            print("didn't raise TypeError")
+        self.assertRaises(TypeError, ssl.RAND_egd, 1)
+        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
         ssl.RAND_add("this is a random string", 75.0)
 
     def test_parse_cert(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -154,6 +154,9 @@
 
 - Issue #13579: string.Formatter now understands the 'a' conversion specifier.
 
+- Issue #15793: Stack corruption in ssl.RAND_egd().
+  Patch by Serhiy Storchaka.
+
 - Issue #15595: Fix subprocess.Popen(universal_newlines=True)
   for certain locales (utf-16 and utf-32 family). Patch by Chris Jerdonek.
 
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1917,7 +1917,7 @@
     PyObject *path;
     int bytes;
 
-    if (!PyArg_ParseTuple(args, "O&|i:RAND_egd",
+    if (!PyArg_ParseTuple(args, "O&:RAND_egd",
                           PyUnicode_FSConverter, &path))
         return NULL;
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list