mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/PrintLib: Add missing return status check for Print APIs
https://bugzilla.tianocore.org/show_bug.cgi?id=307 For the following APIs in PrintLib instance MdeModulePkg\Library\DxePrintLibPrint2Protocol: UnicodeVSPrint UnicodeSPrint UnicodeVSPrintAsciiFormat UnicodeSPrintAsciiFormat AsciiVSPrint AsciiSPrint AsciiVSPrintUnicodeFormat AsciiSPrintUnicodeFormat The internal function DxePrintLibPrint2ProtocolVaListToBaseList() will be called to convert a VA_LIST to a BASE_LIST. However, those APIs miss checking the return value of the internal function. This commit adds codes to check the return value. If the VA_LIST fails to be converted to a BASE_LIST, those PrintLib APIs will return 0 and leave the output 'StartOfBuffer' unmodified. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
8ad05bd26b
commit
7c6075e254
|
@ -6,7 +6,7 @@
|
||||||
protocol related to this implementation, not in the public spec. So, this
|
protocol related to this implementation, not in the public spec. So, this
|
||||||
library instance is only for this code base.
|
library instance is only for this code base.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -71,7 +71,8 @@ PrintLibConstructor (
|
||||||
@param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
|
@param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
|
||||||
@param Size The size, in bytes, of the BaseListMarker buffer.
|
@param Size The size, in bytes, of the BaseListMarker buffer.
|
||||||
|
|
||||||
@return The number of bytes in BaseListMarker. 0 if BaseListMarker is too small.
|
@return TRUE The VA_LIST has been converted to BASE_LIST.
|
||||||
|
@return FALSE The VA_LIST has not been converted to BASE_LIST.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -205,6 +206,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
|
||||||
// If BASE_LIST is larger than Size, then return FALSE
|
// If BASE_LIST is larger than Size, then return FALSE
|
||||||
//
|
//
|
||||||
if ((UINTN)((UINT8 *)BaseListMarker - (UINT8 *)BaseListStart) > Size) {
|
if ((UINTN)((UINT8 *)BaseListMarker - (UINT8 *)BaseListStart) > Size) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "The input variable argument list is too long. Please consider breaking into multiple print calls.\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,15 +266,19 @@ UnicodeVSPrint (
|
||||||
IN VA_LIST Marker
|
IN VA_LIST Marker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
||||||
|
BOOLEAN Converted;
|
||||||
|
|
||||||
DxePrintLibPrint2ProtocolVaListToBaseList (
|
Converted = DxePrintLibPrint2ProtocolVaListToBaseList (
|
||||||
FALSE,
|
FALSE,
|
||||||
(CHAR8 *)FormatString,
|
(CHAR8 *)FormatString,
|
||||||
Marker,
|
Marker,
|
||||||
(BASE_LIST)BaseListMarker,
|
(BASE_LIST)BaseListMarker,
|
||||||
sizeof (BaseListMarker) - 8
|
sizeof (BaseListMarker) - 8
|
||||||
);
|
);
|
||||||
|
if (!Converted) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
return UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
||||||
}
|
}
|
||||||
|
@ -417,15 +423,19 @@ UnicodeVSPrintAsciiFormat (
|
||||||
IN VA_LIST Marker
|
IN VA_LIST Marker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
||||||
|
BOOLEAN Converted;
|
||||||
|
|
||||||
DxePrintLibPrint2ProtocolVaListToBaseList (
|
Converted = DxePrintLibPrint2ProtocolVaListToBaseList (
|
||||||
TRUE,
|
TRUE,
|
||||||
FormatString,
|
FormatString,
|
||||||
Marker,
|
Marker,
|
||||||
(BASE_LIST)BaseListMarker,
|
(BASE_LIST)BaseListMarker,
|
||||||
sizeof (BaseListMarker) - 8
|
sizeof (BaseListMarker) - 8
|
||||||
);
|
);
|
||||||
|
if (!Converted) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
return UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
||||||
}
|
}
|
||||||
|
@ -621,15 +631,19 @@ AsciiVSPrint (
|
||||||
IN VA_LIST Marker
|
IN VA_LIST Marker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
||||||
|
BOOLEAN Converted;
|
||||||
|
|
||||||
DxePrintLibPrint2ProtocolVaListToBaseList (
|
Converted = DxePrintLibPrint2ProtocolVaListToBaseList (
|
||||||
TRUE,
|
TRUE,
|
||||||
FormatString,
|
FormatString,
|
||||||
Marker,
|
Marker,
|
||||||
(BASE_LIST)BaseListMarker,
|
(BASE_LIST)BaseListMarker,
|
||||||
sizeof (BaseListMarker) - 8
|
sizeof (BaseListMarker) - 8
|
||||||
);
|
);
|
||||||
|
if (!Converted) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
return AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
||||||
}
|
}
|
||||||
|
@ -771,15 +785,19 @@ AsciiVSPrintUnicodeFormat (
|
||||||
IN VA_LIST Marker
|
IN VA_LIST Marker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
UINT64 BaseListMarker[256 / sizeof (UINT64)];
|
||||||
|
BOOLEAN Converted;
|
||||||
|
|
||||||
DxePrintLibPrint2ProtocolVaListToBaseList (
|
Converted = DxePrintLibPrint2ProtocolVaListToBaseList (
|
||||||
FALSE,
|
FALSE,
|
||||||
(CHAR8 *)FormatString,
|
(CHAR8 *)FormatString,
|
||||||
Marker,
|
Marker,
|
||||||
(BASE_LIST)BaseListMarker,
|
(BASE_LIST)BaseListMarker,
|
||||||
sizeof (BaseListMarker) - 8
|
sizeof (BaseListMarker) - 8
|
||||||
);
|
);
|
||||||
|
if (!Converted) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
return AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue