[AMD Official Use Only - General] Reviewed-by: Abner Chang <abner.ch...@amd.com>
> -----Original Message----- > From: Nickle Wang <nick...@nvidia.com> > Sent: Friday, January 19, 2024 2:23 PM > To: devel@edk2.groups.io > Cc: Chang, Abner <abner.ch...@amd.com>; Igor Kulchytskyy > <ig...@ami.com>; Nick Ramirez <nrami...@nvidia.com> > Subject: [edk2-redfish-client][PATCH] > RedfishClientPkg/RedfishFeatureUtilityLib: fix wrong parameter issue > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > 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 <nick...@nvidia.com> > Cc: Abner Chang <abner.ch...@amd.com> > Cc: Igor Kulchytskyy <ig...@ami.com> > Cc: Nick Ramirez <nrami...@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 (#114030): https://edk2.groups.io/g/devel/message/114030 Mute This Topic: https://groups.io/mt/103825503/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-