Re: [PATCH v1 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use

Gao, Zhichao
 

For FadtMinorRevision and X_DsdtAddress, I don't think they are required section. Maybe we should consider check the length before check them. As I know, the OVMF's FACP table doesn't have the section after flag.

Thanks,
Zhichao

-----Original Message-----
From: Krzysztof Koch [mailto:krzysztof.koch@...]
Sent: Thursday, August 15, 2019 9:11 PM
To: devel@edk2.groups.io
Cc: Carsey, Jaben <jaben.carsey@...>; Ni, Ray <ray.ni@...>;
Gao, Zhichao <zhichao.gao@...>; Sami.Mujawar@...;
Matteo.Carlini@...; nd@...
Subject: [PATCH v1 03/11] ShellPkg: acpiview: FADT: Validate global pointer
before use

Check if global pointers have been successfully updated before they are
used for further table parsing.

Signed-off-by: Krzysztof Koch <krzysztof.koch@...>
---

Notes:
v1:
- Test against NULL pointers [Krzysztof]

ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
| 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
c
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
c
index
e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..e218e45926abced1096e75441
e22108db7a3a811 100644
---
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
c
+++
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars
+++ er.c
@@ -203,6 +203,20 @@ ParseAcpiFadt (
PARSER_PARAMS (FadtParser)
);

+ // Check if the values used to control the parsing logic have been
+ // successfully read.
+ if ((DsdtAddress == NULL) ||
+ (FadtMinorRevision == NULL) ||
+ (X_DsdtAddress == NULL)) {
+ IncrementErrorCount ();
+ Print (
+ L"ERROR: Insufficient table length. AcpiTableLength = %d. " \
+ L"FADT parsing aborted.\n",
+ AcpiTableLength
+ );
+ return;
+ }
+
if (Trace) {
Print (L"\nSummary:\n");
PrintFieldName (2, L"FADT Version");
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'

Join devel@edk2.groups.io to automatically receive all group messages.