]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly
authorHao Wu <hao.a.wu@intel.com>
Fri, 19 Oct 2018 02:29:36 +0000 (10:29 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 23 Oct 2018 00:45:00 +0000 (08:45 +0800)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1262

Current implementation of BaseLib APIs:

AsciiStrToUnicodeStr()
AsciiStrToUnicodeStrS()
AsciiStrnToUnicodeStrS()

do not handle EASCII properly.

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.

An example:
  0xC9 => 0xFFC9 (current implementations)
and it should be:
  0xC9 => 0x00C9

This commit will address this issue.

Cc: Bin.Lain <bin_601@mail2000.com.tw>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/BaseLib/SafeString.c
MdePkg/Library/BaseLib/String.c

index 29310889cabbfee7f108196ffd0c3c85a6f18ee2..417497cbc96a47aae6f54998df8407c742a78e00 100644 (file)
@@ -2932,7 +2932,7 @@ AsciiStrToUnicodeStrS (
   // Convert string\r
   //\r
   while (*Source != '\0') {\r
-    *(Destination++) = (CHAR16)*(Source++);\r
+    *(Destination++) = (CHAR16)(UINT8)*(Source++);\r
   }\r
   *Destination = '\0';\r
 \r
@@ -3045,7 +3045,7 @@ AsciiStrnToUnicodeStrS (
   // Convert string\r
   //\r
   while ((*Source != 0) && (SourceLen > 0)) {\r
-    *(Destination++) = (CHAR16)*(Source++);\r
+    *(Destination++) = (CHAR16)(UINT8)*(Source++);\r
     SourceLen--;\r
     (*DestinationLength)++;\r
   }\r
index cb90774c862d3e820564f61220cdf90a88d83a53..e6df12797d94d41f60b00020ee02b38dbe65f15d 100644 (file)
@@ -1746,7 +1746,7 @@ AsciiStrToUnicodeStr (
 \r
   ReturnValue = Destination;\r
   while (*Source != '\0') {\r
-    *(Destination++) = (CHAR16) *(Source++);\r
+    *(Destination++) = (CHAR16)(UINT8) *(Source++);\r
   }\r
   //\r
   // End the Destination with a NULL.\r