From: Russell Bryant Date: Thu, 26 Jul 2007 13:20:36 +0000 (+0000) Subject: Ensure that the read from /dev/urandom returns a positive result X-Git-Tag: 1.6.0-beta1~3^2~1913 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ed2deb7df4d7462309d5983760cc20edb3e237c;p=thirdparty%2Fasterisk.git Ensure that the read from /dev/urandom returns a positive result (closes issue #10308, reported by yehavi, patched by me) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77268 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/utils.c b/main/utils.c index fd39d52285..1d73e06122 100644 --- a/main/utils.c +++ b/main/utils.c @@ -830,7 +830,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 res; + return labs(res); } #endif #ifdef linux