Skip to content

Commit

Permalink
Fix infinite loop issue in UsbGetFullHidDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
NishanthSanjeevi committed Mar 4, 2025
1 parent 915cfd7 commit 0b74fb4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions HidPkg/UsbHidDxe/UsbHidDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,12 @@ UsbGetFullHidDescriptor (
}
}

// Check if the descriptor length is 0
if (DescriptorHeader->Len == 0) {
DEBUG ((DEBUG_ERROR, "[%a] Descriptor length is 0\n", __FUNCTION__));
break;
}

// move to next descriptor
DescriptorCursor += DescriptorHeader->Len;
DescriptorHeader = (USB_DESC_HEAD *)((UINT8 *)DescriptorBuffer + DescriptorCursor);
Expand Down

0 comments on commit 0b74fb4

Please sign in to comment.