From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B86F21168206 for ; Fri, 19 Oct 2018 04:23:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 04:23:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="242618160" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 19 Oct 2018 04:23:42 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 04:23:42 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 04:23:41 -0700 Received: from shsmsx152.ccr.corp.intel.com ([169.254.6.209]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.46]) with mapi id 14.03.0319.002; Fri, 19 Oct 2018 19:23:39 +0800 From: "Gao, Liming" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Bin . Lain" , "Yao, Jiewen" , "Kinney, Michael D" Thread-Topic: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly Thread-Index: AQHUZ1i9/+0sljn7oU+LHqCP2PrvGaUmbZCw Date: Fri, 19 Oct 2018 11:23:39 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E342F66@SHSMSX152.ccr.corp.intel.com> References: <20181019030615.9716-1-hao.a.wu@intel.com> In-Reply-To: <20181019030615.9716-1-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODM0MTMyZDUtZTM2MC00YmJlLWFmOGEtZmY4N2E0YTlhNTU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU1FDVk4yendNQjhQMWI2b0FNZWVNUUZTRVh0eWZFK1lTdGV1MVFvcjdIQlQrckV2SzVcL2JzTFBcLzViZmRiTU95In0= dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 11:23:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Wu, Hao A > Sent: Friday, October 19, 2018 11:06 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Bin . Lain ;= Yao, Jiewen ; Kinney, Michael D > ; Gao, Liming > Subject: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCI= I properly >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1262 >=20 > Current implementation of BaseLib APIs: >=20 > AsciiStrToUnicodeStr() > AsciiStrToUnicodeStrS() > AsciiStrnToUnicodeStrS() >=20 > do not handle EASCII properly. >=20 > More specifically, if the value of ASCII character is larger than 0x7F, > then the converted Unicode character will have all '1's in the higher 8 > bits. >=20 > An example: > 0xC9 =3D> 0xFFC9 (current implementations) > and it should be: > 0xC9 =3D> 0x00C9 >=20 > This commit will address this issue. >=20 > Cc: Bin.Lain > Cc: Jiewen Yao > Cc: Michael D Kinney > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdePkg/Library/BaseLib/SafeString.c | 4 ++-- > MdePkg/Library/BaseLib/String.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib= /SafeString.c > index 29310889ca..417497cbc9 100644 > --- a/MdePkg/Library/BaseLib/SafeString.c > +++ b/MdePkg/Library/BaseLib/SafeString.c > @@ -2932,7 +2932,7 @@ AsciiStrToUnicodeStrS ( > // Convert string > // > while (*Source !=3D '\0') { > - *(Destination++) =3D (CHAR16)*(Source++); > + *(Destination++) =3D (CHAR16)(UINT8)*(Source++); > } > *Destination =3D '\0'; >=20 > @@ -3045,7 +3045,7 @@ AsciiStrnToUnicodeStrS ( > // Convert string > // > while ((*Source !=3D 0) && (SourceLen > 0)) { > - *(Destination++) =3D (CHAR16)*(Source++); > + *(Destination++) =3D (CHAR16)(UINT8)*(Source++); > SourceLen--; > (*DestinationLength)++; > } > diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Str= ing.c > index cb90774c86..e6df12797d 100644 > --- a/MdePkg/Library/BaseLib/String.c > +++ b/MdePkg/Library/BaseLib/String.c > @@ -1746,7 +1746,7 @@ AsciiStrToUnicodeStr ( >=20 > ReturnValue =3D Destination; > while (*Source !=3D '\0') { > - *(Destination++) =3D (CHAR16) *(Source++); > + *(Destination++) =3D (CHAR16)(UINT8) *(Source++); > } > // > // End the Destination with a NULL. > -- > 2.12.0.windows.1