[PATCH v2 2/3] OvmfPkg/VirtioGpuDxe: Check QueryMode arguments


Dimitrije Pavlov
 

The current implementation does not check if Info or SizeInfo
pointers are NULL. This causes the SCT test suite to crash.

Add a check to return EFI_INVALID_PARAMETER if any of these
pointers are NULL.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Liming Gao <gaoliming@...>
Cc: Sunny Wang <Sunny.Wang@...>
Cc: Jeff Booher-Kaeding <Jeff.Booher-Kaeding@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@...>
---
OvmfPkg/VirtioGpuDxe/Gop.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 401db47672ec..bb68b1cdc2bc 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -308,7 +308,9 @@ GopQueryMode (
{
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
=20
- if (ModeNumber >=3D This->Mode->MaxMode) {
+ if (Info =3D=3D NULL ||
+ SizeOfInfo =3D=3D NULL ||
+ ModeNumber >=3D This->Mode->MaxMode) {
return EFI_INVALID_PARAMETER;
}
=20
--=20
2.37.2