MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output
This is caused by a previous patch which tried to fix string over-read. It's found that that patch for PrintLib in MdePkg will cause premature terminating of loop used to traversing format string and cause incomplete string output. Because this library uses similar code to do the same job, it has the same issue too. So the fix is also the same. Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@ -2051,7 +2051,9 @@ InternalPrintLibSPrintMarker (
|
|||||||
// ArgumentString is either null-terminated, or it contains Precision characters
|
// ArgumentString is either null-terminated, or it contains Precision characters
|
||||||
//
|
//
|
||||||
for (Count = 0;
|
for (Count = 0;
|
||||||
ArgumentString[Count * BytesPerArgumentCharacter] != '\0' &&
|
(ArgumentString[Count * BytesPerArgumentCharacter] != '\0' ||
|
||||||
|
(BytesPerArgumentCharacter > 1 &&
|
||||||
|
ArgumentString[Count * BytesPerArgumentCharacter + 1]!= '\0')) &&
|
||||||
(Count < Precision || ((Flags & PRECISION) == 0));
|
(Count < Precision || ((Flags & PRECISION) == 0));
|
||||||
Count++) {
|
Count++) {
|
||||||
ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;
|
ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;
|
||||||
@ -2110,7 +2112,9 @@ InternalPrintLibSPrintMarker (
|
|||||||
//
|
//
|
||||||
// Copy the string into the output buffer performing the required type conversions
|
// 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;
|
ArgumentCharacter = ((*ArgumentString & 0xff) | (((UINT8)*(ArgumentString + 1)) << 8)) & ArgumentMask;
|
||||||
|
|
||||||
LengthToReturn += (1 * BytesPerOutputCharacter);
|
LengthToReturn += (1 * BytesPerOutputCharacter);
|
||||||
|
Reference in New Issue
Block a user