From a2ab52d24fb22a68f3e2704cc456fcf30048c05c Mon Sep 17 00:00:00 2001
From: Gregory Maxwell <greg@xiph.org>
Date: Fri, 2 Sep 2011 18:03:43 -0400
Subject: [PATCH] Avoids signed overflow in ectest random number generation.

---
 libcelt/tests/ectest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libcelt/tests/ectest.c b/libcelt/tests/ectest.c
index fb8fe5eef..7daab33e8 100644
--- a/libcelt/tests/ectest.c
+++ b/libcelt/tests/ectest.c
@@ -108,8 +108,8 @@ int main(int _argc,char **_argv){
     unsigned tell_bits;
     int       j;
     int zeros;
-    ft=rand()/((RAND_MAX>>(rand()%11))+1)+10;
-    sz=rand()/((RAND_MAX>>(rand()%9))+1);
+    ft=rand()/((RAND_MAX>>(rand()%11U))+1U)+10;
+    sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
     data=(unsigned *)malloc(sz*sizeof(*data));
     tell=(unsigned *)malloc((sz+1)*sizeof(*tell));
     ec_enc_init(&enc,ptr,DATA_SIZE2);
@@ -170,7 +170,7 @@ int main(int _argc,char **_argv){
     unsigned *tell;
     unsigned *enc_method;
     int       j;
-    sz=rand()/((RAND_MAX>>(rand()%9))+1);
+    sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
     logp1=(unsigned *)malloc(sz*sizeof(*logp1));
     data=(unsigned *)malloc(sz*sizeof(*data));
     tell=(unsigned *)malloc((sz+1)*sizeof(*tell));
-- 
GitLab