[edk2-devel] [PATCH] MdeModulePkg/HiiDatabase: Do not modify CONST string

Jeff Brasen posted 1 patch 2 weeks ago
Failed in applying to current master (apply log)
.../Universal/HiiDatabaseDxe/ConfigRouting.c        | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

[edk2-devel] [PATCH] MdeModulePkg/HiiDatabase: Do not modify CONST string

Posted by Jeff Brasen 2 weeks ago
Update function behavior to not modify the incoming string that is
marked as CONST in the prototype.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Universal/HiiDatabaseDxe/ConfigRouting.c        | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 2cad6d29f4..e08a62c387 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -5497,7 +5497,6 @@ HiiBlockToConfig (
   UINTN                               Index;
   UINT8                               *TemBuffer;
   CHAR16                              *TemString;
-  CHAR16                              TemChar;
 
   TmpBuffer = NULL;
 
@@ -5564,10 +5563,14 @@ HiiBlockToConfig (
   //
   // Copy <ConfigHdr> and an additional '&' to <ConfigResp>
   //
-  TemChar = *StringPtr;
-  *StringPtr = '\0';
-  AppendToMultiString(Config, ConfigRequest);
-  *StringPtr = TemChar;
+
+  TemString = AllocateCopyPool (sizeof (CHAR16) * (StringPtr - ConfigRequest + 1), ConfigRequest);
+  if (TemString == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  TemString[StringPtr - ConfigRequest] = '\0';
+  AppendToMultiString(Config, TemString);
+  FreePool (TemString);
 
   //
   // Parse each <RequestElement> if exists
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56028): https://edk2.groups.io/g/devel/message/56028
Mute This Topic: https://groups.io/mt/72080435/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabase: Do not modify CONST string

Posted by Dandan Bi 1 week ago
Thanks for the update.
Reviewed-by: Dandan Bi <dandan.bi@intel.com>


Thanks,
Dandan

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Jeff Brasen
> Sent: Friday, March 20, 2020 1:21 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Dong, Eric <eric.dong@intel.com>;
> Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabase: Do not modify
> CONST string
> 
> Update function behavior to not modify the incoming string that is marked as
> CONST in the prototype.
> 
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
>  .../Universal/HiiDatabaseDxe/ConfigRouting.c        | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> index 2cad6d29f4..e08a62c387 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> @@ -5497,7 +5497,6 @@ HiiBlockToConfig (
>    UINTN                               Index;
>    UINT8                               *TemBuffer;
>    CHAR16                              *TemString;
> -  CHAR16                              TemChar;
> 
>    TmpBuffer = NULL;
> 
> @@ -5564,10 +5563,14 @@ HiiBlockToConfig (
>    //
>    // Copy <ConfigHdr> and an additional '&' to <ConfigResp>
>    //
> -  TemChar = *StringPtr;
> -  *StringPtr = '\0';
> -  AppendToMultiString(Config, ConfigRequest);
> -  *StringPtr = TemChar;
> +
> +  TemString = AllocateCopyPool (sizeof (CHAR16) * (StringPtr -
> + ConfigRequest + 1), ConfigRequest);  if (TemString == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +  TemString[StringPtr - ConfigRequest] = '\0';
> + AppendToMultiString(Config, TemString);  FreePool (TemString);
> 
>    //
>    // Parse each <RequestElement> if exists
> --
> 2.17.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56153): https://edk2.groups.io/g/devel/message/56153
Mute This Topic: https://groups.io/mt/72080435/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-