]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UsbBusDxe: Fixed USB descriptor length check
authorEvgeny Yakovlev <insoreiges@gmail.com>
Sun, 5 Jun 2016 14:28:31 +0000 (22:28 +0800)
committerFeng Tian <feng.tian@intel.com>
Wed, 29 Jun 2016 02:37:22 +0000 (10:37 +0800)
According to spec if the length of a descriptor is smaller than
what the specification defines, then the host shall ignore it.
However if the size is greater than expected the host will ignore
the extra bytes and start looking for the next descriptor
at the end of actual length returned. Original check did not
handle the latter case correctly and only allowed descriptors
with lengths exactly as defined in specification.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Evgeny Yakovlev <insoreiges@gmail.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c

index 5b8b1aaeae343e15f1c2f25799f3f08dc3aad876..fba60dae16d72b3e27e61ba86dff462f0901e4f1 100644 (file)
@@ -199,8 +199,8 @@ UsbCreateDesc (
     }\r
   }\r
 \r
-  if ((Len <= Offset)      || (Len < Offset + DescLen) ||\r
-      (Head->Type != Type) || (Head->Len != DescLen)) {\r
+  if ((Len <= Offset)      || (Len < Offset + Head->Len) ||\r
+      (Head->Type != Type) || (Head->Len < DescLen)) {\r
     DEBUG (( EFI_D_ERROR, "UsbCreateDesc: met mal-format descriptor\n"));\r
     return NULL;\r
   }\r