Blob Blame History Raw
From dab3a04fbd2c4658614471cd4d8550ce0e0cef7b Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Thu, 10 Dec 2020 16:38:26 +0900
Subject: [PATCH] beats/draw_beats: avoid integer overflow by multiplication

gcc10 -fsanitize=undefined detects the following integer overflow:
------------------------------------------
../../../hacks/glx/beats.c:325:53: runtime error: signed integer overflow: 3665625 * 42587 cannot be represented in type 'int'
../../../hacks/glx/beats.c:326:21: runtime error: signed integer overflow: 1489149219 * 1233599 cannot be represented in type 'int'
------------------------------------------
Avoid this by using unsigned integer. ->
Patch revised by the upstream
---
 hacks/glx/beats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hacks/glx/beats.c b/hacks/glx/beats.c
index 64fd689..19565ec 100644
--- a/hacks/glx/beats.c
+++ b/hacks/glx/beats.c
@@ -229,9 +229,9 @@ draw_beats (ModeInfo *mi)
   Bool sineWaveTick = bp->use_tick;
   Bool motionBlur = bp->use_blur;
   size_t cycle, dist;
-  int tmS, tmM, tmH, tmD;
-  uint64_t timeSeed;
-  int64_t timeDelta = 0;
+  unsigned int tmS, tmM, tmH, tmD;
+  unsigned int timeSeed;
+  int timeDelta = 0;
   size_t blurOffset = 10; /* offset per blur frame, in milliseconds */
   size_t framesPerBlur = 20;  /* number of sub-frames to blur */
   size_t deltaLimit = (motionBlur) ? (blurOffset * framesPerBlur) : 1;
-- 
2.29.2