// Handle repeat key\r
//\r
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, CurKeyCodeBuffer[Index]);\r
+ ASSERT (KeyDescriptor != NULL);\r
+\r
if (KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER || KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER) {\r
//\r
// For NumLock or CapsLock pressed, there is no need to handle repeat key for them.\r
RemoveKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), &UsbKey);\r
\r
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode);\r
+ ASSERT (KeyDescriptor != NULL);\r
+\r
if (!UsbKey.Down) {\r
//\r
// Key is released.\r
@retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.\r
@retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.\r
@retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER\r
+ @retval EFI_DEVICE_ERROR Keyboard layout is invalid.\r
\r
**/\r
EFI_STATUS\r
}\r
\r
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, KeyCode);\r
+ ASSERT (KeyDescriptor != NULL);\r
\r
if (KeyDescriptor->Modifier == EFI_NS_KEY_MODIFIER) {\r
//\r
UsbKeyboardDevice->CurrentNsKey = NULL;\r
}\r
\r
+ //\r
+ // Make sure modifier of Key Descriptor is in the valid range according to UEFI spec.\r
+ //\r
+ if (KeyDescriptor->Modifier > EFI_FUNCTION_KEY_TWELVE_MODIFIER) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
Key->ScanCode = ModifierValueToEfiScanCodeConvertionTable[KeyDescriptor->Modifier];\r
Key->UnicodeChar = KeyDescriptor->Unicode;\r
\r
RemoveKeyCode (KeyboardBuffer, &UsbKey);\r
}\r
\r
+ ASSERT (KeyboardBuffer->BufferTail <= MAX_KEY_ALLOWED);\r
+\r
KeyboardBuffer->Buffer[KeyboardBuffer->BufferTail].KeyCode = Key;\r
KeyboardBuffer->Buffer[KeyboardBuffer->BufferTail].Down = Down;\r
\r
return EFI_DEVICE_ERROR;\r
}\r
\r
+ ASSERT (KeyboardBuffer->BufferHead <= MAX_KEY_ALLOWED);\r
+\r
UsbKey->KeyCode = KeyboardBuffer->Buffer[KeyboardBuffer->BufferHead].KeyCode;\r
UsbKey->Down = KeyboardBuffer->Buffer[KeyboardBuffer->BufferHead].Down;\r
\r