From 3ed2deb7df4d7462309d5983760cc20edb3e237c Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Thu, 26 Jul 2007 13:20:36 +0000
Subject: [PATCH] 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
---
 main/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
GitLab