X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePrintLib%2FPrintLib.c;h=e940bedb3497aec3b32b83c5fa29b49f7008609e;hp=24e01755451352ad7af165cd77b0047abe63f8f6;hb=8960cdebac8c75f13f1cb6afa932f0ae323a138b;hpb=ad82307c753df478012953df517006c58cd7b8a4 diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c index 24e0175545..e940bedb34 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -66,7 +66,6 @@ static CONST STATUS_LOOKUP_TABLE_ENTRY StatusString[] = { @param Buffer Character buffer to print the results of the parsing of Format into. @param BufferSize Maximum number of characters to put into buffer. - Zero means no limit. @param Flags Intial flags value. Can only have FORMAT_UNICODE and OUTPUT_UNICODE set @param Format Null-terminated format string. @@ -110,6 +109,9 @@ BasePrintLibVSPrint ( UINTN Radix; RETURN_STATUS Status; + if (BufferSize == 0) { + return 0; + } ASSERT (Buffer != NULL); ASSERT (Format != NULL); @@ -130,7 +132,6 @@ BasePrintLibVSPrint ( // // Reserve space for the Null terminator. - // If BufferSize is 0, this will set BufferSize to the max unsigned value // BufferSize--; @@ -338,7 +339,7 @@ BasePrintLibVSPrint ( } else { BasePrintLibSPrint ( ValueBuffer, - 0, + MAXIMUM_VALUE_CHARACTERS, 0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", TmpGuid->Data1, @@ -364,7 +365,7 @@ BasePrintLibVSPrint ( } else { BasePrintLibSPrint ( ValueBuffer, - 0, + MAXIMUM_VALUE_CHARACTERS, 0, "%02d/%02d/%04d %02d:%02d", TmpTime->Month, @@ -386,10 +387,14 @@ BasePrintLibVSPrint ( } } if (ArgumentString == ValueBuffer) { - BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status); + BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status); } break; + case '\n': + ArgumentString = "\r\n"; + break; + case '%': default: // @@ -400,9 +405,6 @@ BasePrintLibVSPrint ( break; } break; - case '\n': - ArgumentString = "\r\n"; - break; default: ArgumentString = (CHAR8 *)&FormatCharacter; Flags |= ARGUMENT_UNICODE; @@ -717,7 +719,7 @@ UnicodeSPrintAsciiFormat ( VA_LIST Marker; VA_START (Marker, FormatString); - return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker); + return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker); } /**