diff options
author | Wang, Jian J <jian.j.wang@intel.com> | 2018-01-02 16:20:20 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-01-02 16:31:19 +0800 |
commit | 701e8cc29a283d6d598695592ca2469cdacddf64 (patch) | |
tree | 03b0db465853639ed1bd76c57e303f31398b9f81 /MdePkg/Library/BasePrintLib | |
parent | cd16355bbf3267f1ad7f678e91dc60cf31f3cb29 (diff) | |
download | edk2-701e8cc29a283d6d598695592ca2469cdacddf64.tar.gz edk2-701e8cc29a283d6d598695592ca2469cdacddf64.tar.bz2 edk2-701e8cc29a283d6d598695592ca2469cdacddf64.zip |
MdePkg/BasePrintLib: Fix incomplete print output
This is caused by previous patch which tried to fix string over-read,
which breaks UEFI menu rendering: the following
/------------------------------------------------------------------------------\
| Device Manager |
\------------------------------------------------------------------------------/
is rendered as
/\
| Device Manager |
\/.0 2.00 GHz
(the spurious digits are SMBIOS data from the home screen)
The problem appears to be that the CHAR16 value of BOXDRAW_HORIZONTAL
equals 0x2500, which means that testing ArgumentString[] != '\0'
(which tests the low byte only) will yield FALSE and terminate the
loop prematurely.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/Library/BasePrintLib')
-rw-r--r-- | MdePkg/Library/BasePrintLib/PrintLibInternal.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index fc57255068..6f19b31449 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -1108,7 +1108,9 @@ BasePrintLibSPrintMarker ( // ArgumentString is either null-terminated, or it contains Precision characters
//
for (Count = 0;
- ArgumentString[Count * BytesPerArgumentCharacter] != '\0' &&
+ (ArgumentString[Count * BytesPerArgumentCharacter] != '\0' ||
+ (BytesPerArgumentCharacter > 1 &&
+ ArgumentString[Count * BytesPerArgumentCharacter + 1]!= '\0')) &&
(Count < Precision || ((Flags & PRECISION) == 0));
Count++) {
ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;
@@ -1167,7 +1169,9 @@ BasePrintLibSPrintMarker ( //
// Copy the string into the output buffer performing the required type conversions
//
- while (Index < Count && (*ArgumentString) != '\0') {
+ while (Index < Count &&
+ (ArgumentString[0] != '\0' ||
+ (BytesPerArgumentCharacter > 1 && ArgumentString[1] != '\0'))) {
ArgumentCharacter = ((*ArgumentString & 0xff) | (((UINT8)*(ArgumentString + 1)) << 8)) & ArgumentMask;
LengthToReturn += (1 * BytesPerOutputCharacter);
|