File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
218
218
struct usb_interface_descriptor * altsd ;
219
219
void * control_header ;
220
220
int i , protocol ;
221
+ int rest_bytes ;
221
222
222
223
/* find audiocontrol interface */
223
224
host_iface = & usb_ifnum_to_if (dev , ctrlif )-> altsetting [0 ];
@@ -232,6 +233,15 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
232
233
return - EINVAL ;
233
234
}
234
235
236
+ rest_bytes = (void * )(host_iface -> extra + host_iface -> extralen ) -
237
+ control_header ;
238
+
239
+ /* just to be sure -- this shouldn't hit at all */
240
+ if (rest_bytes <= 0 ) {
241
+ dev_err (& dev -> dev , "invalid control header\n" );
242
+ return - EINVAL ;
243
+ }
244
+
235
245
switch (protocol ) {
236
246
default :
237
247
dev_warn (& dev -> dev ,
@@ -242,11 +252,21 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
242
252
case UAC_VERSION_1 : {
243
253
struct uac1_ac_header_descriptor * h1 = control_header ;
244
254
255
+ if (rest_bytes < sizeof (* h1 )) {
256
+ dev_err (& dev -> dev , "too short v1 buffer descriptor\n" );
257
+ return - EINVAL ;
258
+ }
259
+
245
260
if (!h1 -> bInCollection ) {
246
261
dev_info (& dev -> dev , "skipping empty audio interface (v1)\n" );
247
262
return - EINVAL ;
248
263
}
249
264
265
+ if (rest_bytes < h1 -> bLength ) {
266
+ dev_err (& dev -> dev , "invalid buffer length (v1)\n" );
267
+ return - EINVAL ;
268
+ }
269
+
250
270
if (h1 -> bLength < sizeof (* h1 ) + h1 -> bInCollection ) {
251
271
dev_err (& dev -> dev , "invalid UAC_HEADER (v1)\n" );
252
272
return - EINVAL ;
You can’t perform that action at this time.
0 commit comments