[asterisk-commits] mmichelson: trunk r89487 - /trunk/main/utils.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 21 12:19:23 CST 2007
Author: mmichelson
Date: Wed Nov 21 12:19:22 2007
New Revision: 89487
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89487
Log:
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)
Modified:
trunk/main/utils.c
Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=89487&r1=89486&r2=89487
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Wed Nov 21 12:19:22 2007
@@ -1140,7 +1140,7 @@
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
More information about the asterisk-commits
mailing list