]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
play: Fix integer overflow in com_ff().
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 19 Apr 2024 18:35:02 +0000 (20:35 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 19 Apr 2024 18:40:07 +0000 (20:40 +0200)
The product of the number of chunks and the number of seconds to skip
may overflow the 32 bit multiplication. Add a cast to force 64 bit
arithmetics to avoid the overflow.

play.c

diff --git a/play.c b/play.c
index ffdc8555ce6686833b846f9610a3d81f6adf03cb..e5e053b95e49fb4fad9d412c39b6e30f20924a1b 100644 (file)
--- a/play.c
+++ b/play.c
@@ -955,7 +955,7 @@ static int com_ff(struct lls_parse_result *lpr)
        seconds += get_play_time();
        seconds = PARA_MIN(seconds, (typeof(seconds))pt->seconds - 4);
        seconds = PARA_MAX(seconds, 0);
-       pt->start_chunk = pt->num_chunks * seconds / pt->seconds;
+       pt->start_chunk = (uint64_t)pt->num_chunks * seconds / pt->seconds;
        pt->start_chunk = PARA_MIN(pt->start_chunk, pt->num_chunks - 1);
        pt->start_chunk = PARA_MAX(pt->start_chunk, 0UL);
        if (!pt->playing)