pointer verification (not NULL) and buffer overrun fixes.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11459 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -340,55 +340,56 @@ DisplaySysEventLogData (
|
||||
//
|
||||
Offset = 0;
|
||||
Log = (LOG_RECORD_FORMAT *) LogData;
|
||||
while (Log->Type != END_OF_LOG && Offset < LogAreaLength) {
|
||||
while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) {
|
||||
//
|
||||
// Get a Event Log Record
|
||||
//
|
||||
Log = (LOG_RECORD_FORMAT *) (LogData + Offset);
|
||||
|
||||
//
|
||||
// Display Event Log Record Information
|
||||
//
|
||||
DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);
|
||||
DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);
|
||||
if (Log != NULL) {
|
||||
//
|
||||
// Display Event Log Record Information
|
||||
//
|
||||
DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);
|
||||
DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);
|
||||
|
||||
Offset += Log->Length;
|
||||
Offset += Log->Length;
|
||||
//
|
||||
// Display Log Header Date/Time Fields
|
||||
// These fields contain the BCD representation of the date and time
|
||||
// (as read from CMOS) of the occurrence of the event
|
||||
// So Print as hex and represent decimal
|
||||
//
|
||||
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);
|
||||
if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {
|
||||
Print (L"19");
|
||||
} else if (Log != NULL && Log->Year <= 79) {
|
||||
Print (L"20");
|
||||
} else {
|
||||
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Display Log Header Date/Time Fields
|
||||
// These fields contain the BCD representation of the date and time
|
||||
// (as read from CMOS) of the occurrence of the event
|
||||
// So Print as hex and represent decimal
|
||||
//
|
||||
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);
|
||||
if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {
|
||||
Print (L"19");
|
||||
} else if (Log != NULL && Log->Year <= 79) {
|
||||
Print (L"20");
|
||||
} else {
|
||||
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);
|
||||
continue;
|
||||
ShellPrintHiiEx(-1,-1,NULL,
|
||||
STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),
|
||||
gShellDebug1HiiHandle,
|
||||
Log->Year,
|
||||
Log->Month,
|
||||
Log->Day,
|
||||
Log->Hour,
|
||||
Log->Minute,
|
||||
Log->Second
|
||||
);
|
||||
|
||||
//
|
||||
// Display Variable Data Format
|
||||
//
|
||||
if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ElVdfType = Log->LogVariableData[0];
|
||||
DisplayElVdfInfo (ElVdfType, Log->LogVariableData);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx(-1,-1,NULL,
|
||||
STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),
|
||||
gShellDebug1HiiHandle,
|
||||
Log->Year,
|
||||
Log->Month,
|
||||
Log->Day,
|
||||
Log->Hour,
|
||||
Log->Minute,
|
||||
Log->Second
|
||||
);
|
||||
|
||||
//
|
||||
// Display Variable Data Format
|
||||
//
|
||||
if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ElVdfType = Log->LogVariableData[0];
|
||||
DisplayElVdfInfo (ElVdfType, Log->LogVariableData);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
Build a table, each item is (Key, Info) pair.
|
||||
And give a interface of query a string out of a table.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
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
|
||||
@ -2921,27 +2921,8 @@ TABLE_ITEM StructureTypeInfoTable[] = {
|
||||
};
|
||||
|
||||
|
||||
UINT8
|
||||
QueryTable (
|
||||
IN TABLE_ITEM *Table,
|
||||
IN UINTN Number,
|
||||
IN UINT8 Key,
|
||||
IN OUT CHAR16 *Info
|
||||
)
|
||||
/*++
|
||||
Routine Description:
|
||||
Function Description
|
||||
Given a table and a Key, return the responding info.
|
||||
|
||||
Arguments:
|
||||
Table - The begin address of table
|
||||
Number - The number of table items
|
||||
Key - The query Key
|
||||
Info - Input as empty buffer; output as data buffer.
|
||||
|
||||
Returns:
|
||||
if Key found - return found Key and Info
|
||||
if Key unfound - return QUERY_TABLE_UNFOUND, Info=NULL
|
||||
/**
|
||||
Given a table and a Key, return the responding info.
|
||||
|
||||
Notes:
|
||||
Table[Index].Key is change from UINT8 to UINT16,
|
||||
@ -2955,7 +2936,23 @@ Routine Description:
|
||||
Then all the Key Value between Low and High gets the same string
|
||||
L"Unused".
|
||||
|
||||
@param[in] Table The begin address of table.
|
||||
@param[in] Number The number of table items.
|
||||
@param[in] Key The query Key.
|
||||
@param[in,out] Info Input as empty buffer; output as data buffer.
|
||||
@param[in] InfoLen The max number of characters for Info.
|
||||
|
||||
@return the found Key and Info is valid.
|
||||
@retval QUERY_TABLE_UNFOUND and Info should be NULL.
|
||||
**/
|
||||
UINT8
|
||||
QueryTable (
|
||||
IN TABLE_ITEM *Table,
|
||||
IN UINTN Number,
|
||||
IN UINT8 Key,
|
||||
IN OUT CHAR16 *Info,
|
||||
IN UINTN InfoLen
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
//
|
||||
@ -2971,7 +2968,7 @@ Routine Description:
|
||||
// Check if Key is in the range
|
||||
//
|
||||
if (High > Low && Key >= Low && Key <= High) {
|
||||
StrCpy (Info, Table[Index].Info);
|
||||
StrnCpy (Info, Table[Index].Info, InfoLen-1);
|
||||
StrCat (Info, L"\n");
|
||||
return Key;
|
||||
}
|
||||
@ -2979,13 +2976,13 @@ Routine Description:
|
||||
// Check if Key == Value in the table
|
||||
//
|
||||
if (Table[Index].Key == Key) {
|
||||
StrCpy (Info, Table[Index].Info);
|
||||
StrnCpy (Info, Table[Index].Info, InfoLen-1);
|
||||
StrCat (Info, L"\n");
|
||||
return Key;
|
||||
}
|
||||
}
|
||||
|
||||
StrCpy (Info, L"Undefined Value\n");
|
||||
StrnCpy (Info, L"Undefined Value\n", InfoLen);
|
||||
return QUERY_TABLE_UNFOUND;
|
||||
}
|
||||
|
||||
@ -3069,7 +3066,7 @@ PrintBitsInfo (
|
||||
CHAR16 Info[66]; \
|
||||
Num = sizeof (Table) / sizeof (TABLE_ITEM); \
|
||||
ZeroMem (Info, sizeof (Info)); \
|
||||
QueryTable (Table, Num, Key, Info); \
|
||||
QueryTable (Table, Num, Key, Info, sizeof(Info)/sizeof(Info[0])); \
|
||||
Print (Info); \
|
||||
} while (0);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Build a table, each item is (key, info) pair.
|
||||
and give a interface of query a string out of a table.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
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
|
||||
@ -37,12 +37,37 @@ typedef struct TABLE_ITEM {
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
Given a table and a Key, return the responding info.
|
||||
|
||||
Notes:
|
||||
Table[Index].Key is change from UINT8 to UINT16,
|
||||
in order to deal with "0xaa - 0xbb".
|
||||
|
||||
For example:
|
||||
DisplaySELVariableDataFormatTypes(UINT8 Type, UINT8 Option)
|
||||
has a item:
|
||||
"0x07-0x7F, Unused"
|
||||
Now define Key = 0x7F07, that is to say: High = 0x7F, Low = 0x07.
|
||||
Then all the Key Value between Low and High gets the same string
|
||||
L"Unused".
|
||||
|
||||
@param[in] Table The begin address of table.
|
||||
@param[in] Number The number of table items.
|
||||
@param[in] Key The query Key.
|
||||
@param[in,out] Info Input as empty buffer; output as data buffer.
|
||||
@param[in] InfoLen The max number of characters for Info.
|
||||
|
||||
@return the found Key and Info is valid.
|
||||
@retval QUERY_TABLE_UNFOUND and Info should be NULL.
|
||||
**/
|
||||
UINT8
|
||||
QueryTable (
|
||||
IN TABLE_ITEM *Table,
|
||||
IN UINTN Number,
|
||||
IN UINT8 Key,
|
||||
IN OUT CHAR16 *Info
|
||||
IN OUT CHAR16 *Info,
|
||||
IN UINTN InfoLen
|
||||
);
|
||||
|
||||
VOID
|
||||
|
Reference in New Issue
Block a user