[edk2] [PATCH v2] MdeModulePkg/UefiHiiLib:Fix incorrect comparison expression

Dandan Bi posted 1 patch 7 years, 7 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[edk2] [PATCH v2] MdeModulePkg/UefiHiiLib:Fix incorrect comparison expression
Posted by Dandan Bi 7 years, 7 months ago
https://bugzilla.tianocore.org/show_bug.cgi?id=416

V2: The pointer StringPtr points to a string returned
by ExtractConfig/ExportConfig, if it is NULL, function 
InternalHiiIfrValueAction will return FALSE. So in 
current usage model, the StringPtr can not be NULL before
using it, so we can add ASSERT here.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index a2abf26..cd0cd35 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -2199,12 +2199,13 @@ InternalHiiIfrValueAction (
   if (EFI_ERROR (Status)) {
     return FALSE;
   }
   
   StringPtr = ConfigAltResp;
-  
-  while (StringPtr != L'\0') {
+  ASSERT (StringPtr != NULL);
+
+  while (*StringPtr != L'\0') {
     //
     // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
     //
     StringHdr = StringPtr;
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2] MdeModulePkg/UefiHiiLib:Fix incorrect comparison expression
Posted by Dong, Eric 7 years, 7 months ago
Reviewed-by: Eric Dong <eric.dong@intel.com>

-----Original Message-----
From: Bi, Dandan 
Sent: Wednesday, April 5, 2017 11:11 AM
To: edk2-devel@lists.01.org
Cc: Dong, Eric; Gao, Liming
Subject: [PATCH v2] MdeModulePkg/UefiHiiLib:Fix incorrect comparison expression

https://bugzilla.tianocore.org/show_bug.cgi?id=416

V2: The pointer StringPtr points to a string returned by ExtractConfig/ExportConfig, if it is NULL, function InternalHiiIfrValueAction will return FALSE. So in current usage model, the StringPtr can not be NULL before using it, so we can add ASSERT here.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index a2abf26..cd0cd35 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -2199,12 +2199,13 @@ InternalHiiIfrValueAction (
   if (EFI_ERROR (Status)) {
     return FALSE;
   }
   
   StringPtr = ConfigAltResp;
-
-  while (StringPtr != L'\0') {
+  ASSERT (StringPtr != NULL);
+
+  while (*StringPtr != L'\0') {
     //
     // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
     //
     StringHdr = StringPtr;
 
-- 
1.9.5.msysgit.1

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