mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/UsbBus: Reject descriptor whose length is bad
Today's implementation doesn't check whether the length of descriptor is valid before using it. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
parent
4c034bf62c
commit
70c3c2370a
|
@ -772,6 +772,13 @@ UsbGetOneConfig (
|
|||
|
||||
DEBUG (( EFI_D_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
|
||||
|
||||
//
|
||||
// Reject if TotalLength even cannot cover itself.
|
||||
//
|
||||
if (Desc.TotalLength < OFFSET_OF (EFI_USB_CONFIG_DESCRIPTOR, TotalLength) + sizeof (Desc.TotalLength)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Buf = AllocateZeroPool (Desc.TotalLength);
|
||||
|
||||
if (Buf == NULL) {
|
||||
|
|
Loading…
Reference in New Issue