public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue
@ 2024-01-19  6:23 Nickle Wang via groups.io
  2024-01-19  8:21 ` Chang, Abner via groups.io
  0 siblings, 1 reply; 2+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-19  6:23 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez

Third parameter of AsciiStrToUnicodeStrS is the number of character in
destination buffer, not the size in byte of destination buffer. This
creates failure of converting ASCII string to Unicode string in Redfish
application while getting Location field in HTTP header.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
 .../RedfishFeatureUtilityLib.c                         | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index a10fa4832..e14944710 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -355,7 +355,7 @@ StrUnicodeToAscii (
 
   Status = UnicodeStrToAsciiStrS (UnicodeStr, AsciiStr, AsciiStrSize);
   if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "UnicodeStrToAsciiStrS failed: %r\n", Status));
+    DEBUG ((DEBUG_ERROR, "%a: UnicodeStrToAsciiStrS failed: %r\n", __func__, Status));
     FreePool (AsciiStr);
     return NULL;
   }
@@ -380,21 +380,23 @@ StrAsciiToUnicode (
 {
   EFI_STRING  UnicodeStr;
   UINTN       UnicodeStrSize;
+  UINTN       InputStrSize;
   EFI_STATUS  Status;
 
   if (IS_EMPTY_STRING (AsciiStr)) {
     return NULL;
   }
 
-  UnicodeStrSize = (AsciiStrLen (AsciiStr) + 1) * sizeof (CHAR16);
+  InputStrSize   = AsciiStrSize (AsciiStr);
+  UnicodeStrSize = InputStrSize * sizeof (CHAR16);
   UnicodeStr     = AllocatePool (UnicodeStrSize);
   if (UnicodeStr == NULL) {
     return NULL;
   }
 
-  Status = AsciiStrToUnicodeStrS (AsciiStr, UnicodeStr, UnicodeStrSize);
+  Status = AsciiStrToUnicodeStrS (AsciiStr, UnicodeStr, InputStrSize);
   if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "t failed: %r\n", Status));
+    DEBUG ((DEBUG_ERROR, "%a: AsciiStrToUnicodeStrS failed: %r\n", __func__, Status));
     FreePool (UnicodeStr);
     return NULL;
   }
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114028): https://edk2.groups.io/g/devel/message/114028
Mute This Topic: https://groups.io/mt/103825503/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-19  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-19  6:23 [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue Nickle Wang via groups.io
2024-01-19  8:21 ` Chang, Abner via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox