Skip to content

Commit

Permalink
RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Abner Chang <abner.chang@amd.com>
  • Loading branch information
nicklela committed Jan 22, 2024
1 parent d7a6e97 commit effd42a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit effd42a

Please sign in to comment.