mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-24 14:56:58 +00:00
There existed about a 1 in 4 billion chance that reading from /dev/urandom
would return LONG_MIN (1 in 9 quintillion if using 64-bit longs). Since there is no positive equivalent of LONG_MIN, the result of labs() in this case is unpredictable. This fixes that situation. (closes issue #11336, reported and patched by sperreault) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1140,7 +1140,7 @@ long int ast_random(void)
|
||||
if (dev_urandom_fd >= 0) {
|
||||
int read_res = read(dev_urandom_fd, &res, sizeof(res));
|
||||
if (read_res > 0)
|
||||
return labs(res);
|
||||
return res < 0 ? ~res : res;
|
||||
}
|
||||
#endif
|
||||
#ifdef linux
|
||||
|
Reference in New Issue
Block a user