ALSA: rawmidi: fix incorrect array bounds check on clock_names
Subsystems (2)
PATCH 1/1 ALSA: rawmidi: fix incorrect array bounds check on clock_names
From: Colin Ian King <[email protected]>
The array bounds check on clock_names is currently checking the size of the entire array rather than the number of elements in the array leading to a potential array bounds read error. Fix this by using the ARRAY_SIZE macro instead of sizeof.
Addresses-Coverity: ("Out-of-bounds read")
Fixes 08fdced60ca0 ("ALSA: rawmidi: Add framing mode")
Signed-off-by Colin Ian King <[email protected]>
--- sound/core/rawmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/rawmidi.c +1 -1
@@ -1679,7 +1679,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, buffer_size, avail, xruns);if (substream->framing ==SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP ) { clock_type = substream->clock_type >>SNDRV_RAWMIDI_MODE_CLOCK_SHIFT ; -if (!snd_BUG_ON (clock_type >=sizeof (clock_names))) +if (!snd_BUG_ON (clock_type >=ARRAY_SIZE (clock_names))) snd_iprintf(buffer, " Framing : tstamp\n" " Clock type : %s\n",
Signature · 1 line
2.31.1
Takashi Iwai
AppliedQuoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
The array bounds check on
clock_namesis currently checking the size of the entire array rather than the number of elements in the array leading to a potential array bounds read error. Fix this by using theARRAY_SIZEmacro instead of sizeof.Addresses-Coverity: ("Out-of-bounds read")
Fixes 08fdced60ca0 ("ALSA: rawmidi: Add framing mode")Signed-off-by Colin Ian King <[email protected]>
Thanks, applied.
Takashi