[patch] MdeModulePkg/HiiDB: Handle the "&READONLY" tag in <KeywordResp> correctly


Dandan Bi
 

This patch is to fix the incorrect logic when handling the "&READONLY" tag
in <KeywordResp>.
1. In UEFI spec, the "&READONLY" tag is in upper case, but using the lower
case in current codes by mistake.
2. The logic in checking the ReadOnly flag is not correct. Whether having
"&READONLY" tag must be consistent with the result of
"ExtractReadOnlyFromOpCode" function.

Cc: Liming Gao <liming.gao@...>
Cc: Eric Dong <eric.dong@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@...>
---
.../Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 6682319..10a901f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -2905,15 +2905,15 @@ EfiConfigKeywordHandlerSetData (
goto Done;
}
StringPtr = NextStringPtr;

//
- // 5. Find ReadOnly filter.
+ // 5. Find READONLY tag.
//
- if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&ReadOnly", StrLen (L"&ReadOnly")) == 0) {
+ if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&READONLY", StrLen (L"&READONLY")) == 0) {
ReadOnly = TRUE;
- StringPtr += StrLen (L"&ReadOnly");
+ StringPtr += StrLen (L"&READONLY");
} else {
ReadOnly = FALSE;
}

//
@@ -2935,13 +2935,22 @@ EfiConfigKeywordHandlerSetData (

//
// 8. Check the readonly flag.
//
if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {
+ //
+ // Extracting readonly flag form opcode and extracting "READONLY" tag form KeywordString should have the same results.
+ // If not, the input KeywordString must be incorrect, return the error status to caller.
+ //
+ *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ if (ReadOnly) {
*ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;
Status = EFI_ACCESS_DENIED;
- goto Done;
+ goto Done;
}

//
// 9. Merge to the MultiKeywordResp string.
//
--
1.9.5.msysgit.1


Dong, Eric
 

Reviewed-by: Eric Dong <eric.dong@...>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@...] On Behalf Of Dandan Bi
Sent: Thursday, September 08, 2016 5:10 PM
To: edk2-devel@...
Cc: Dong, Eric; Gao, Liming
Subject: [edk2] [patch] MdeModulePkg/HiiDB: Handle the "&READONLY" tag in <KeywordResp> correctly

This patch is to fix the incorrect logic when handling the "&READONLY" tag
in <KeywordResp>.
1. In UEFI spec, the "&READONLY" tag is in upper case, but using the lower
case in current codes by mistake.
2. The logic in checking the ReadOnly flag is not correct. Whether having
"&READONLY" tag must be consistent with the result of
"ExtractReadOnlyFromOpCode" function.

Cc: Liming Gao <liming.gao@...>
Cc: Eric Dong <eric.dong@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@...>
---
.../Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 6682319..10a901f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -2905,15 +2905,15 @@ EfiConfigKeywordHandlerSetData (
goto Done;
}
StringPtr = NextStringPtr;

//
- // 5. Find ReadOnly filter.
+ // 5. Find READONLY tag.
//
- if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&ReadOnly", StrLen (L"&ReadOnly")) == 0) {
+ if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&READONLY", StrLen (L"&READONLY")) == 0) {
ReadOnly = TRUE;
- StringPtr += StrLen (L"&ReadOnly");
+ StringPtr += StrLen (L"&READONLY");
} else {
ReadOnly = FALSE;
}

//
@@ -2935,13 +2935,22 @@ EfiConfigKeywordHandlerSetData (

//
// 8. Check the readonly flag.
//
if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {
+ //
+ // Extracting readonly flag form opcode and extracting "READONLY" tag form KeywordString should have the same results.
+ // If not, the input KeywordString must be incorrect, return the error status to caller.
+ //
+ *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ if (ReadOnly) {
*ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;
Status = EFI_ACCESS_DENIED;
- goto Done;
+ goto Done;
}

//
// 9. Merge to the MultiKeywordResp string.
//
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@...
https://lists.01.org/mailman/listinfo/edk2-devel


Liming Gao
 

Reviewed-by: Liming Gao <liming.gao@...>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@...] On Behalf Of
Dandan Bi
Sent: Thursday, September 08, 2016 5:10 PM
To: edk2-devel@...
Cc: Dong, Eric <eric.dong@...>; Gao, Liming <liming.gao@...>
Subject: [edk2] [patch] MdeModulePkg/HiiDB: Handle the "&READONLY" tag
in <KeywordResp> correctly

This patch is to fix the incorrect logic when handling the "&READONLY" tag
in <KeywordResp>.
1. In UEFI spec, the "&READONLY" tag is in upper case, but using the lower
case in current codes by mistake.
2. The logic in checking the ReadOnly flag is not correct. Whether having
"&READONLY" tag must be consistent with the result of
"ExtractReadOnlyFromOpCode" function.

Cc: Liming Gao <liming.gao@...>
Cc: Eric Dong <eric.dong@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@...>
---
.../Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 17
+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git
a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 6682319..10a901f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -2905,15 +2905,15 @@ EfiConfigKeywordHandlerSetData (
goto Done;
}
StringPtr = NextStringPtr;

//
- // 5. Find ReadOnly filter.
+ // 5. Find READONLY tag.
//
- if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&ReadOnly", StrLen
(L"&ReadOnly")) == 0) {
+ if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&READONLY", StrLen
(L"&READONLY")) == 0) {
ReadOnly = TRUE;
- StringPtr += StrLen (L"&ReadOnly");
+ StringPtr += StrLen (L"&READONLY");
} else {
ReadOnly = FALSE;
}

//
@@ -2935,13 +2935,22 @@ EfiConfigKeywordHandlerSetData (

//
// 8. Check the readonly flag.
//
if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {
+ //
+ // Extracting readonly flag form opcode and extracting "READONLY" tag
form KeywordString should have the same results.
+ // If not, the input KeywordString must be incorrect, return the error
status to caller.
+ //
+ *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ if (ReadOnly) {
*ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;
Status = EFI_ACCESS_DENIED;
- goto Done;
+ goto Done;
}

//
// 9. Merge to the MultiKeywordResp string.
//
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@...
https://lists.01.org/mailman/listinfo/edk2-devel