Commit e53f47f6 authored by Dongxiang Ke's avatar Dongxiang Ke Committed by Takashi Iwai
Browse files

ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()



There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and
the number of it's interfaces less than 4, an out-of-bounds read bug occurs
when parsing the interface descriptor for this device.

Fix this by checking the number of interfaces.

Signed-off-by: default avatarDongxiang Ke <kdx.glider@gmail.com>
Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8d44e604
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1106,7 +1106,7 @@ static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip,
	 * Dallas DS4201 workaround: It presents 5 altsettings, but the last
	 * one misses syncpipe, and does not produce any sound.
	 */
	if (chip->usb_id == USB_ID(0x04fa, 0x4201))
	if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4)
		num = 4;

	for (i = 0; i < num; i++) {