usbhost/enumerate: fix possible buffer overwrite

This commit is contained in:
Janne Rosberg 2016-10-18 08:15:19 -06:00 committed by Gregory Nutt
parent f01c5b79fc
commit 72f13db4bf

View File

@ -469,6 +469,14 @@ int usbhost_enumerate(FAR struct usbhost_hubport_s *hport,
cfglen = (unsigned int)usbhost_getle16(((struct usb_cfgdesc_s *)buffer)->totallen);
uinfo("sizeof config data: %d\n", cfglen);
if (cfglen > maxlen)
{
uerr("ERROR: Configuration doesn't fit in buffer, length=%d, maxlen=%d\n",
cfglen, maxlen);
ret = -E2BIG;
goto errout;
}
/* Get all of the configuration descriptor data, index == 0 (Should not be
* hard-coded!)
*/