public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>,
	Igor Kulchytskyy <igork@ami.com>,
	"Nick Ramirez" <nramirez@nvidia.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue
Date: Fri, 19 Jan 2024 14:23:05 +0800	[thread overview]
Message-ID: <20240119062305.5208-1-nicklew@nvidia.com> (raw)

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]
-=-=-=-=-=-=-=-=-=-=-=-



             reply	other threads:[~2024-01-19  6:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  6:23 Nickle Wang via groups.io [this message]
2024-01-19  8:21 ` [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue Chang, Abner via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240119062305.5208-1-nicklew@nvidia.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox