Message285007
It looks like the logic for handling an error seeding from urandom is reversed: <https://hg.python.org/cpython/rev/45fc0c83ed42#l6.66>. Random_seed_urandom() actually returns -1 if is an exception set, and 0 if it was successful.
The result would be a normal working urandom setup ignores urandom and seeds from the time and PID. Not a big deal, since the old code always seeded from a (lower resolution) time anyway. But if urandom failed, we get the SystemError.
The fix should be simple, in Modules/_randommodule.c change the random_seed() function to read
if (arg == NULL || arg == Py_None) {
if (random_seed_urandom(self) < 0) { // was >= 0!
PyErr_Clear();
/* Reading system entropy failed, fall back on the worst entropy:
use the current time and process identifier. */
random_seed_time_pid(self);
}
Py_RETURN_NONE;
} |
|
Date |
User |
Action |
Args |
2017-01-08 21:20:02 | martin.panter | set | recipients:
+ martin.panter, vstinner, virtuald |
2017-01-08 21:20:02 | martin.panter | set | messageid: <1483910402.86.0.327009779042.issue29208@psf.upfronthosting.co.za> |
2017-01-08 21:20:02 | martin.panter | link | issue29208 messages |
2017-01-08 21:20:02 | martin.panter | create | |
|