File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
283
283
struct usb_interface_descriptor * altsd ;
284
284
struct usb_interface * usb_iface ;
285
285
int i , protocol ;
286
+ int rest_bytes ;
286
287
287
288
usb_iface = usb_ifnum_to_if (dev , ctrlif );
288
289
if (!usb_iface ) {
@@ -324,12 +325,32 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
324
325
return - EINVAL ;
325
326
}
326
327
328
+ rest_bytes = (void * )(host_iface -> extra + host_iface -> extralen )
329
+ - control_header ;
330
+
331
+ /* just to be sure -- this shouldn't hit at all */
332
+ if (rest_bytes <= 0 ) {
333
+ dev_err (& dev -> dev , "invalid control header\n" );
334
+ return - EINVAL ;
335
+ }
336
+
327
337
h1 = control_header ;
338
+
339
+ if (rest_bytes < sizeof (* h1 )) {
340
+ dev_err (& dev -> dev , "too short v1 buffer descriptor\n" );
341
+ return - EINVAL ;
342
+ }
343
+
328
344
if (!h1 -> bInCollection ) {
329
345
dev_info (& dev -> dev , "skipping empty audio interface (v1)\n" );
330
346
return - EINVAL ;
331
347
}
332
348
349
+ if (rest_bytes < h1 -> bLength ) {
350
+ dev_err (& dev -> dev , "invalid buffer length (v1)\n" );
351
+ return - EINVAL ;
352
+ }
353
+
333
354
if (h1 -> bLength < sizeof (* h1 ) + h1 -> bInCollection ) {
334
355
dev_err (& dev -> dev , "invalid UAC_HEADER (v1)\n" );
335
356
return - EINVAL ;
You can’t perform that action at this time.
0 commit comments