mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcStringLib: Fix safe SPrint va_arg usage
This commit is contained in:
parent
c25f05f9df
commit
641f72e7f3
@ -142,6 +142,7 @@ OcAsciiSafeSPrint (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VA_LIST Marker;
|
||||
VA_LIST Marker2;
|
||||
UINTN NumberOfPrinted;
|
||||
|
||||
ASSERT (StartOfBuffer != NULL);
|
||||
@ -149,13 +150,19 @@ OcAsciiSafeSPrint (
|
||||
ASSERT (FormatString != NULL);
|
||||
|
||||
VA_START (Marker, FormatString);
|
||||
NumberOfPrinted = SPrintLengthAsciiFormat (FormatString, Marker);
|
||||
|
||||
VA_COPY (Marker2, Marker);
|
||||
NumberOfPrinted = SPrintLengthAsciiFormat (FormatString, Marker2);
|
||||
VA_END (Marker2);
|
||||
|
||||
if (BufferSize - 1 >= NumberOfPrinted) {
|
||||
AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
VA_END (Marker);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -187,6 +187,7 @@ OcUnicodeSafeSPrint (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VA_LIST Marker;
|
||||
VA_LIST Marker2;
|
||||
UINTN NumberOfPrinted;
|
||||
|
||||
ASSERT (StartOfBuffer != NULL);
|
||||
@ -194,13 +195,19 @@ OcUnicodeSafeSPrint (
|
||||
ASSERT (FormatString != NULL);
|
||||
|
||||
VA_START (Marker, FormatString);
|
||||
NumberOfPrinted = SPrintLength (FormatString, Marker);
|
||||
|
||||
VA_COPY (Marker2, Marker);
|
||||
NumberOfPrinted = SPrintLength (FormatString, Marker2);
|
||||
VA_END (Marker2);
|
||||
|
||||
if (BufferSize - 1 >= NumberOfPrinted) {
|
||||
UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
VA_END (Marker);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user