public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly
@ 2018-10-19  3:06 Hao Wu
  2018-10-19 11:23 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2018-10-19  3:06 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Bin . Lain, Jiewen Yao, Michael D Kinney, Liming Gao

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>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdePkg/Library/BaseLib/SafeString.c | 4 ++--
 MdePkg/Library/BaseLib/String.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

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 != '\0') {
-    *(Destination++) = (CHAR16)*(Source++);
+    *(Destination++) = (CHAR16)(UINT8)*(Source++);
   }
   *Destination = '\0';
 
@@ -3045,7 +3045,7 @@ AsciiStrnToUnicodeStrS (
   // Convert string
   //
   while ((*Source != 0) && (SourceLen > 0)) {
-    *(Destination++) = (CHAR16)*(Source++);
+    *(Destination++) = (CHAR16)(UINT8)*(Source++);
     SourceLen--;
     (*DestinationLength)++;
   }
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index cb90774c86..e6df12797d 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -1746,7 +1746,7 @@ AsciiStrToUnicodeStr (
 
   ReturnValue = Destination;
   while (*Source != '\0') {
-    *(Destination++) = (CHAR16) *(Source++);
+    *(Destination++) = (CHAR16)(UINT8) *(Source++);
   }
   //
   // End the Destination with a NULL.
-- 
2.12.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly
  2018-10-19  3:06 [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly Hao Wu
@ 2018-10-19 11:23 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-10-19 11:23 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org
  Cc: Bin . Lain, Yao, Jiewen, Kinney, Michael D

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Wu, Hao A
> Sent: Friday, October 19, 2018 11:06 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Bin . Lain <bin_601@mail2000.com.tw>; Yao, Jiewen <jiewen.yao@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly
> 
> 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>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  MdePkg/Library/BaseLib/SafeString.c | 4 ++--
>  MdePkg/Library/BaseLib/String.c     | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> 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 != '\0') {
> -    *(Destination++) = (CHAR16)*(Source++);
> +    *(Destination++) = (CHAR16)(UINT8)*(Source++);
>    }
>    *Destination = '\0';
> 
> @@ -3045,7 +3045,7 @@ AsciiStrnToUnicodeStrS (
>    // Convert string
>    //
>    while ((*Source != 0) && (SourceLen > 0)) {
> -    *(Destination++) = (CHAR16)*(Source++);
> +    *(Destination++) = (CHAR16)(UINT8)*(Source++);
>      SourceLen--;
>      (*DestinationLength)++;
>    }
> diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
> index cb90774c86..e6df12797d 100644
> --- a/MdePkg/Library/BaseLib/String.c
> +++ b/MdePkg/Library/BaseLib/String.c
> @@ -1746,7 +1746,7 @@ AsciiStrToUnicodeStr (
> 
>    ReturnValue = Destination;
>    while (*Source != '\0') {
> -    *(Destination++) = (CHAR16) *(Source++);
> +    *(Destination++) = (CHAR16)(UINT8) *(Source++);
>    }
>    //
>    // End the Destination with a NULL.
> --
> 2.12.0.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-19 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19  3:06 [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly Hao Wu
2018-10-19 11:23 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox