]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: Fix out-of-bound access in stereo VU meter drawing
authorTakashi Iwai <tiwai@suse.de>
Tue, 24 Aug 2021 08:06:05 +0000 (10:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 24 Aug 2021 08:06:05 +0000 (10:06 +0200)
The left channel drawing of a stereo VU meter has a bug where it may
access a negative array index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay/aplay.c

index a51a37ba34bd18fbdae0fff9e9ccfcc679932859..63a4e3437fd97a801dd4bd1dc37f310f4794b04b 100644 (file)
@@ -1758,10 +1758,12 @@ static void print_vu_meter_stereo(int *perc, int *maxperc)
                if (c)
                        memset(line + bar_length + 6 + 1, '#', p);
                else
-                       memset(line + bar_length - p - 1, '#', p);
-               p = maxperc[c] * bar_length / 100;
-               if (p > bar_length)
-                       p = bar_length;
+                       memset(line + bar_length - p, '#', p);
+               p = maxperc[c] * bar_length / 100 - 1;
+               if (p < 0)
+                       p = 0;
+               else if (p >= bar_length)
+                       p = bar_length - 1;
                if (c)
                        line[bar_length + 6 + 1 + p] = '+';
                else