]> granicus.if.org Git - python/commitdiff
On Windows, silence a Purify warning and initialize the memory passed to CryptGenRandom.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 21 Jul 2008 21:06:46 +0000 (21:06 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 21 Jul 2008 21:06:46 +0000 (21:06 +0000)
Since python doesn't provide any particular random data, it seems more reasonable anyway.

Modules/posixmodule.c

index 6af6e513d5e45c723be078fdda57024c03b5c063..f18e1546eb0b3ae14720e5e5aaeb70dfed619be7 100644 (file)
@@ -8250,6 +8250,7 @@ win32_urandom(PyObject *self, PyObject *args)
        result = PyString_FromStringAndSize(NULL, howMany);
        if (result != NULL) {
                /* Get random data */
+               memset(PyString_AS_STRING(result), 0, howMany); /* zero seed */
                if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
                                      PyString_AS_STRING(result))) {
                        Py_DECREF(result);