From: Jesus Cea Date: Tue, 11 Sep 2012 00:00:58 +0000 (+0200) Subject: Closes #15793: Stack corruption in ssl.RAND_egd() X-Git-Tag: v3.3.1rc1~813^2~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8754a13e607ebc70f12a10297c76dc574a91d5b;p=python Closes #15793: Stack corruption in ssl.RAND_egd() --- diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 551151e873..d4c5e6351a 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -103,12 +103,8 @@ class BasicSocketTests(unittest.TestCase): 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 index 725fb9e5c1..3b09e9633a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -154,6 +154,9 @@ Library - 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 index 0a841183a5..e9de8cad27 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1917,7 +1917,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *args) PyObject *path; int bytes; - if (!PyArg_ParseTuple(args, "O&|i:RAND_egd", + if (!PyArg_ParseTuple(args, "O&:RAND_egd", PyUnicode_FSConverter, &path)) return NULL;