Handle incorrect parameters passed to DisplayDxe GOP functions
QueryMode(), SetMode(), and Blt().
This fixes Blt_Conf and QueryMode_Conf failures
reported by SCT tests at:
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fissues%2F73&data=02%7C01%7Cawarkentin%40vmware.com%7C34c31d6924ca4f871d1b08d82de317b2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637309800678733611&sdata=3BSdjglhhk%2FqRrP0mDOxV8YydE4vf0FdDkMnzabV5qY%3D&reserved=0
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
---
Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
index b880ca827bd6..80d0f7b2cb3c 100644
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
@@ -1,5 +1,6 @@
/** @file
*
+ * Copyright (c) 2020, ARM Limited. All rights reserved.
* Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
* Copyright (c) Microsoft Corporation. All rights reserved.
*
@@ -170,7 +171,7 @@ DisplayQueryMode (
EFI_STATUS Status;
GOP_MODE_DATA *Mode;
- if (ModeNumber > mLastMode) {
+ if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {
return EFI_INVALID_PARAMETER;
}
@@ -227,7 +228,7 @@ DisplaySetMode (
EFI_PHYSICAL_ADDRESS FbBase;
GOP_MODE_DATA *Mode = &mGopModeData[ModeNumber];
- if (ModeNumber > mLastMode) {
+ if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
@@ -299,6 +300,14 @@ DisplayBlt (
UINT8 *VidBuf, *BltBuf, *VidBuf1;
UINTN i;
+ if ((UINTN)BltOperation >= EfiGraphicsOutputBltOperationMax) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Width == 0 || Height == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
switch (BltOperation) {
case EfiBltVideoFill:
BltBuf = (UINT8*)BltBuffer;
@@ -349,7 +358,7 @@ DisplayBlt (
break;
default:
- ASSERT_EFI_ERROR (EFI_SUCCESS);
+ return EFI_INVALID_PARAMETER;
break;
}
--
2.17.1