[asterisk-commits] file: trunk r89637 - /trunk/main/utils.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 27 11:01:19 CST 2007
Author: file
Date: Tue Nov 27 11:01:19 2007
New Revision: 89637
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89637
Log:
Ensure the value returned from ast_random is between 0 and RAND_MAX on 64-bit platforms.
(closes issue #11348)
Reported 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=89637&r1=89636&r2=89637
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Tue Nov 27 11:01:19 2007
@@ -1139,8 +1139,10 @@
if (dev_urandom_fd >= 0) {
int read_res = read(dev_urandom_fd, &res, sizeof(res));
if (read_res > 0) {
+ long int rm = RAND_MAX;
res = res < 0 ? ~res : res;
- return res;
+ rm++;
+ return res % rm;
}
}
#endif
More information about the asterisk-commits
mailing list