MdeModulePkg/Ps2Mouse: Fix potential buffer overflow issue.
Count is initially 1 but is assigned to 2 in case PS2_READ_DATA_BYTE. Though the state machine doesn't go back from PS2_READ_DATA_BYTE to PS2_READ_BYTE_ONE (not a true bug), force assign Count to 1 to avoid potential buffer overflow issue. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Shumin Qiu <shumin.qiu@intel.com>
This commit is contained in:
@@ -343,7 +343,6 @@ PS2MouseGetPacket (
|
|||||||
BOOLEAN RButton;
|
BOOLEAN RButton;
|
||||||
|
|
||||||
KeyboardEnable = FALSE;
|
KeyboardEnable = FALSE;
|
||||||
Count = 1;
|
|
||||||
State = PS2_READ_BYTE_ONE;
|
State = PS2_READ_BYTE_ONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -357,6 +356,7 @@ PS2MouseGetPacket (
|
|||||||
// Read mouse first byte data, if failed, immediately return
|
// Read mouse first byte data, if failed, immediately return
|
||||||
//
|
//
|
||||||
KbcDisableAux ();
|
KbcDisableAux ();
|
||||||
|
Count = 1;
|
||||||
Status = PS2MouseRead (&Data, &Count, State);
|
Status = PS2MouseRead (&Data, &Count, State);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
KbcEnableAux ();
|
KbcEnableAux ();
|
||||||
|
Reference in New Issue
Block a user