It looks to me like InternalSearchForGaugeEntry() could dereference a NULL
pointer? It seems it is legal for Token or Module to be NULL, but they are
passed into AsciiStrnCmp()? It looks like AsciiStrSize() will ASSERT() if
SecondString is NULL?
Am I missing something here? Or is this a real issue?
Thanks,
Andrew Fish
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
UINT32
InternalSearchForGaugeEntry (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
IN UINT32 Identifier
)
{
UINT32 Index;
UINT32 Index2;
UINT32 NumberOfEntries;
GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
if (Token == NULL) {
Token = "";
}
if (Module == NULL) {
Module = "";
}
NumberOfEntries = mGaugeData->NumberOfEntries;
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
Index2 = 0;
for (Index = 0; Index < NumberOfEntries; Index++) {
Index2 = NumberOfEntries - 1 - Index;
if (GaugeEntryExArray[Index2].EndTimeStamp == 0 &&
(GaugeEntryExArray[Index2].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN)
Handle) &&
AsciiStrnCmp (GaugeEntryExArray[Index2].Token, Token,
DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
AsciiStrnCmp (GaugeEntryExArray[Index2].Module, Module,
DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
(GaugeEntryExArray[Index2].Identifier == Identifier)) {
Index = Index2;
break;
}
}
return Index;
}
/**
Compares two Null-terminated ASCII strings with maximum lengths, and returns
the difference between the first mismatched ASCII characters.
This function compares the Null-terminated ASCII string FirstString to the
Null-terminated ASCII string SecondString. At most, Length ASCII characters
will be compared. If Length is 0, then 0 is returned. If FirstString is
identical to SecondString, then 0 is returned. Otherwise, the value returned
is the first mismatched ASCII character in SecondString subtracted from the
first mismatched ASCII character in FirstString.
If Length > 0 and FirstString is NULL, then ASSERT().
If Length > 0 and SecondString is NULL, then ASSERT().
If PcdMaximumAsciiStringLength is not zero, and Length is greater than
PcdMaximumAsciiStringLength, then ASSERT().
If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
PcdMaximumAsciiStringLength ASCII characters, not including the
Null-terminator,
then ASSERT().
If PcdMaximumAsciiStringLength is not zero, and SecondString contains more
than
PcdMaximumAsciiStringLength ASCII characters, not including the
Null-terminator,
then ASSERT().
@param FirstString The pointer to a Null-terminated ASCII string.
@param SecondString The pointer to a Null-terminated ASCII string.
@param Length The maximum number of ASCII characters for compare.
@retval ==0 FirstString is identical to SecondString.
@retval !=0 FirstString is not identical to SecondString.
**/
INTN
EFIAPI
AsciiStrCmp (
IN CONST CHAR8 *FirstString,
IN CONST CHAR8 *SecondString
)
{
//
// ASSERT both strings are less long than PcdMaximumAsciiStringLength
//
ASSERT (AsciiStrSize (FirstString));
ASSERT (AsciiStrSize (SecondString));
while ((*FirstString != '\0') && (*FirstString == *SecondString)) {
FirstString++;
SecondString++;
}
return *FirstString - *SecondString;
}
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel