Ensure that the read from /dev/urandom returns a positive result
authorRussell Bryant <russell@russellbryant.com>
Thu, 26 Jul 2007 13:20:36 +0000 (13:20 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 26 Jul 2007 13:20:36 +0000 (13:20 +0000)
(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

main/utils.c

index fd39d52..1d73e06 100644 (file)
@@ -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