ShellInfoObject.ShellInitSettings.Delay = 0;\r
} else if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay) {\r
TempConst = ShellCommandLineGetValue(Package, L"-delay");\r
- if (*TempConst == L':') {\r
+ if (TempConst != NULL && *TempConst == L':') {\r
TempConst++;\r
}\r
if (TempConst != NULL && !EFI_ERROR(ShellConvertStringToUint64(TempConst, &Intermediate, FALSE, FALSE))) {\r
FilePathSize = GetDevicePathSize (FilePath);\r
\r
TempByteBuffer = AllocateZeroPool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize);\r
- TempByteStart = TempByteBuffer;\r
- *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes\r
- TempByteBuffer += sizeof (UINT32);\r
+ if (TempByteBuffer != NULL) {\r
+ TempByteStart = TempByteBuffer;\r
+ *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes\r
+ TempByteBuffer += sizeof (UINT32);\r
\r
- *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength\r
- TempByteBuffer += sizeof (UINT16);\r
+ *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength\r
+ TempByteBuffer += sizeof (UINT16);\r
\r
- CopyMem (TempByteBuffer, Desc, DescSize);\r
- TempByteBuffer += DescSize;\r
- CopyMem (TempByteBuffer, FilePath, FilePathSize);\r
+ CopyMem (TempByteBuffer, Desc, DescSize);\r
+ TempByteBuffer += DescSize;\r
+ CopyMem (TempByteBuffer, FilePath, FilePathSize);\r
\r
- UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);\r
- Status = gRT->SetVariable (\r
- OptionStr,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
- TempByteStart\r
- );\r
-\r
- FreePool(TempByteStart);\r
+ UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);\r
+ Status = gRT->SetVariable (\r
+ OptionStr,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
+ TempByteStart\r
+ );\r
+\r
+ FreePool(TempByteStart);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, OptionStr, Status);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0]));\r
- NewCount = OrderCount;\r
- CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
- for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){\r
- if (NewOrder[LoopVar] == Location) {\r
- CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));\r
- NewCount--;\r
+ if (NewOrder != NULL) {\r
+ NewCount = OrderCount;\r
+ CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
+ for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){\r
+ if (NewOrder[LoopVar] == Location) {\r
+ CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));\r
+ NewCount--;\r
+ }\r
}\r
+ Status = gRT->SetVariable(\r
+ Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
+ (EFI_GUID*)&gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
+ NewCount*sizeof(NewOrder[0]),\r
+ NewOrder);\r
+ FreePool(NewOrder);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
}\r
- Status = gRT->SetVariable(\r
- Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
- (EFI_GUID*)&gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
- NewCount*sizeof(NewOrder[0]),\r
- NewOrder);\r
- FreePool(NewOrder);\r
-\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status);\r
return (SHELL_INVALID_PARAMETER);\r
// if > 0, the advance\r
//\r
if (Count <= 0) {\r
- AbsCount = -Count;\r
+ AbsCount = (UINTN)ABS(Count);\r
Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
} else {\r
- Line = InternalEditorMiscLineAdvance (Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
+ Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
}\r
\r
return Line;\r
CurrentLine = FileBuffer.CurrentLine;\r
Line = MoveLine (FRow - FileBuffer.FilePosition.Row);\r
\r
- if (FColumn > Line->Size) {\r
+ if (Line == NULL || FColumn > Line->Size) {\r
HasCharacter = FALSE;\r
}\r
\r
Limit = 0;\r
}\r
\r
- StrnCpy (PrintLine, Buffer, Limit > MainEditor.ScreenSize.Column ? MainEditor.ScreenSize.Column : Limit);\r
+ StrnCpy (PrintLine, Buffer, MIN(MIN(Limit,MainEditor.ScreenSize.Column), 200));\r
for (; Limit < MainEditor.ScreenSize.Column; Limit++) {\r
PrintLine[Limit] = L' ';\r
}\r
//\r
// if is the old file\r
//\r
- if (StrCmp (FileName, FileBuffer.FileName) == 0) {\r
+ if (FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) == 0) {\r
//\r
// file has not been modified\r
//\r
//\r
// if that line, is not that long, so move to the end of that line\r
//\r
- if (FCol > Line->Size) {\r
+ if (Line != NULL && FCol > Line->Size) {\r
FCol = Line->Size + 1;\r
}\r
\r
//\r
// if that line is not that long, so move to the end of that line\r
//\r
- if (FCol > Line->Size) {\r
+ if (Line != NULL && FCol > Line->Size) {\r
FCol = Line->Size + 1;\r
}\r
\r
UINTN AbsCount;\r
\r
if (Count <= 0) {\r
- AbsCount = -Count;\r
+ AbsCount = (UINTN)ABS(Count);\r
Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
} else {\r
- Line = InternalEditorMiscLineAdvance (Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
+ Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);\r
}\r
\r
if (Line == NULL) {\r
//\r
FileBuffer.FilePosition.Row = NewFilePosRow;\r
if (RowGap < 0) {\r
- Abs = -RowGap;\r
+ Abs = (UINTN)ABS(RowGap);\r
FileBuffer.DisplayPosition.Row -= Abs;\r
} else {\r
FileBuffer.DisplayPosition.Row += RowGap;\r
CurrentLine = HBufferImage.CurrentLine;\r
Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);\r
\r
- if (FColumn > Line->Size) {\r
+ if (Line == NULL || FColumn > Line->Size) {\r
HasCharacter = FALSE;\r
}\r
\r
//\r
HBufferImage.BufferPosition.Row = NewFilePosRow;\r
if (RowGap <= 0) {\r
- Abs = -RowGap;\r
+ Abs = (UINTN)ABS(RowGap);\r
HBufferImage.DisplayPosition.Row -= Abs;\r
} else {\r
HBufferImage.DisplayPosition.Row += RowGap;\r
//\r
// if that line, is not that long, so move to the end of that line\r
//\r
- if (FCol > Line->Size) {\r
+ if (Line != NULL && FCol > Line->Size) {\r
FCol = Line->Size + 1;\r
HighBits = TRUE;\r
}\r
//\r
// if is the old file\r
//\r
- if (StrCmp (FileName, HFileImage.FileName) == 0) {\r
+ if (HFileImage.FileName != NULL && FileName != NULL && StrCmp (FileName, HFileImage.FileName) == 0) {\r
//\r
// check whether file exists on disk\r
//\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
Name = ShellCommandLineGetRawValue(Package, 1);\r
- if (!IsValidFileName(Name)) {\r
+ if (Name == NULL || !IsValidFileName(Name)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
// do not set currentline to Line\r
//\r
if (Count <= 0) {\r
- AbsCount = -Count;\r
+ AbsCount = (UINTN)ABS(Count);\r
Line = _HLineRetreat (AbsCount);\r
} else {\r
- Line = _HLineAdvance (Count);\r
+ Line = _HLineAdvance ((UINTN)Count);\r
}\r
\r
return Line;\r
// >0: advance\r
//\r
if (Count <= 0) {\r
- AbsCount = -Count;\r
+ AbsCount = (UINTN)ABS(Count);\r
Line = _HLineRetreat (AbsCount);\r
} else {\r
- Line = _HLineAdvance (Count);\r
+ Line = _HLineAdvance ((UINTN)Count);\r
}\r
\r
if (Line == NULL) {\r
Lenp = StrLen (Pat);\r
Lens = StrLen (Str);\r
\r
- Failure = AllocateZeroPool (Lenp * sizeof (INTN));\r
+ Failure = AllocateZeroPool ((UINTN)(Lenp * sizeof (INTN)));\r
+ if (Failure == NULL) {\r
+ return 0;\r
+ }\r
Failure[0] = -1;\r
for (j = 1; j < Lenp; j++) {\r
i = Failure[j - 1];\r
// arbitrary buffer\r
//\r
Buffer = AllocateZeroPool((StrLen(Data) / 2));\r
- for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) {\r
- ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16);\r
- ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1]));\r
+ if (Buffer == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ } else {\r
+ for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) {\r
+ ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16);\r
+ ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1]));\r
+ }\r
+ Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer);\r
}\r
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer);\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status);\r
ShellStatus = SHELL_ACCESS_DENIED;\r
//\r
Data++;\r
Buffer = AllocateZeroPool(StrSize(Data) / 2);\r
- AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data);\r
- ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] = CHAR_NULL;\r
-\r
- \r
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer);\r
+ if (Buffer == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ } else {\r
+ AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data);\r
+ ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] = CHAR_NULL;\r
+ Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer);\r
+ }\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status);\r
ShellStatus = SHELL_ACCESS_DENIED;\r
//\r
Offset = 0;\r
Log = (LOG_RECORD_FORMAT *) LogData;\r
- while (Log->Type != END_OF_LOG && Offset < LogAreaLength) {\r
+ while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) {\r
//\r
// Get a Event Log Record\r
//\r
Log = (LOG_RECORD_FORMAT *) (LogData + Offset);\r
\r
- //\r
- // Display Event Log Record Information\r
- //\r
- DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);\r
- DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);\r
-\r
- Offset += Log->Length;\r
-\r
- //\r
- // Display Log Header Date/Time Fields\r
- // These fields contain the BCD representation of the date and time\r
- // (as read from CMOS) of the occurrence of the event\r
- // So Print as hex and represent decimal\r
- //\r
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);\r
- if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {\r
- Print (L"19");\r
- } else if (Log != NULL && Log->Year <= 79) {\r
- Print (L"20");\r
- } else {\r
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);\r
- continue;\r
+ if (Log != NULL) {\r
+ //\r
+ // Display Event Log Record Information\r
+ //\r
+ DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);\r
+ DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);\r
+\r
+ Offset += Log->Length;\r
+ //\r
+ // Display Log Header Date/Time Fields\r
+ // These fields contain the BCD representation of the date and time\r
+ // (as read from CMOS) of the occurrence of the event\r
+ // So Print as hex and represent decimal\r
+ //\r
+ ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);\r
+ if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {\r
+ Print (L"19");\r
+ } else if (Log != NULL && Log->Year <= 79) {\r
+ Print (L"20");\r
+ } else {\r
+ ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);\r
+ continue;\r
+ }\r
+\r
+ ShellPrintHiiEx(-1,-1,NULL,\r
+ STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),\r
+ gShellDebug1HiiHandle,\r
+ Log->Year,\r
+ Log->Month,\r
+ Log->Day,\r
+ Log->Hour,\r
+ Log->Minute,\r
+ Log->Second\r
+ );\r
+\r
+ //\r
+ // Display Variable Data Format\r
+ //\r
+ if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {\r
+ continue;\r
+ }\r
+\r
+ ElVdfType = Log->LogVariableData[0];\r
+ DisplayElVdfInfo (ElVdfType, Log->LogVariableData);\r
}\r
-\r
- ShellPrintHiiEx(-1,-1,NULL,\r
- STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),\r
- gShellDebug1HiiHandle,\r
- Log->Year,\r
- Log->Month,\r
- Log->Day,\r
- Log->Hour,\r
- Log->Minute,\r
- Log->Second\r
- );\r
-\r
- //\r
- // Display Variable Data Format\r
- //\r
- if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {\r
- continue;\r
- }\r
-\r
- ElVdfType = Log->LogVariableData[0];\r
- DisplayElVdfInfo (ElVdfType, Log->LogVariableData);\r
}\r
}\r
Build a table, each item is (Key, Info) pair.\r
And give a interface of query a string out of a table.\r
\r
- Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
};\r
\r
\r
-UINT8\r
-QueryTable (\r
- IN TABLE_ITEM *Table,\r
- IN UINTN Number,\r
- IN UINT8 Key,\r
- IN OUT CHAR16 *Info\r
- )\r
-/*++\r
-Routine Description:\r
- Function Description\r
- Given a table and a Key, return the responding info.\r
-\r
- Arguments:\r
- Table - The begin address of table\r
- Number - The number of table items\r
- Key - The query Key\r
- Info - Input as empty buffer; output as data buffer.\r
-\r
- Returns:\r
- if Key found - return found Key and Info\r
- if Key unfound - return QUERY_TABLE_UNFOUND, Info=NULL\r
+/**\r
+ Given a table and a Key, return the responding info.\r
\r
Notes:\r
Table[Index].Key is change from UINT8 to UINT16,\r
Then all the Key Value between Low and High gets the same string\r
L"Unused".\r
\r
+ @param[in] Table The begin address of table.\r
+ @param[in] Number The number of table items.\r
+ @param[in] Key The query Key.\r
+ @param[in,out] Info Input as empty buffer; output as data buffer.\r
+ @param[in] InfoLen The max number of characters for Info.\r
+\r
+ @return the found Key and Info is valid.\r
+ @retval QUERY_TABLE_UNFOUND and Info should be NULL.\r
**/\r
+UINT8\r
+QueryTable (\r
+ IN TABLE_ITEM *Table,\r
+ IN UINTN Number,\r
+ IN UINT8 Key,\r
+ IN OUT CHAR16 *Info,\r
+ IN UINTN InfoLen\r
+ )\r
{\r
UINTN Index;\r
//\r
// Check if Key is in the range\r
//\r
if (High > Low && Key >= Low && Key <= High) {\r
- StrCpy (Info, Table[Index].Info);\r
+ StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
StrCat (Info, L"\n");\r
return Key;\r
}\r
// Check if Key == Value in the table\r
//\r
if (Table[Index].Key == Key) {\r
- StrCpy (Info, Table[Index].Info);\r
+ StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
StrCat (Info, L"\n");\r
return Key;\r
}\r
}\r
\r
- StrCpy (Info, L"Undefined Value\n");\r
+ StrnCpy (Info, L"Undefined Value\n", InfoLen);\r
return QUERY_TABLE_UNFOUND;\r
}\r
\r
CHAR16 Info[66]; \\r
Num = sizeof (Table) / sizeof (TABLE_ITEM); \\r
ZeroMem (Info, sizeof (Info)); \\r
- QueryTable (Table, Num, Key, Info); \\r
+ QueryTable (Table, Num, Key, Info, sizeof(Info)/sizeof(Info[0])); \\r
Print (Info); \\r
} while (0);\r
\r
Build a table, each item is (key, info) pair.\r
and give a interface of query a string out of a table.\r
\r
- Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
} \\r
} while (0);\r
\r
+/**\r
+ Given a table and a Key, return the responding info.\r
+\r
+ Notes:\r
+ Table[Index].Key is change from UINT8 to UINT16,\r
+ in order to deal with "0xaa - 0xbb".\r
+\r
+ For example:\r
+ DisplaySELVariableDataFormatTypes(UINT8 Type, UINT8 Option)\r
+ has a item:\r
+ "0x07-0x7F, Unused"\r
+ Now define Key = 0x7F07, that is to say: High = 0x7F, Low = 0x07.\r
+ Then all the Key Value between Low and High gets the same string\r
+ L"Unused".\r
+\r
+ @param[in] Table The begin address of table.\r
+ @param[in] Number The number of table items.\r
+ @param[in] Key The query Key.\r
+ @param[in,out] Info Input as empty buffer; output as data buffer.\r
+ @param[in] InfoLen The max number of characters for Info.\r
+\r
+ @return the found Key and Info is valid.\r
+ @retval QUERY_TABLE_UNFOUND and Info should be NULL.\r
+**/\r
UINT8\r
QueryTable (\r
IN TABLE_ITEM *Table,\r
IN UINTN Number,\r
IN UINT8 Key,\r
- IN OUT CHAR16 *Info\r
+ IN OUT CHAR16 *Info,\r
+ IN UINTN InfoLen\r
);\r
\r
VOID\r
TempCopy = StrnCatGrow(&TempCopy, NULL, StringGuid, 0);\r
Walker = TempCopy;\r
TempSpot = StrStr(Walker, L"-");\r
- *TempSpot = CHAR_NULL;\r
+ if (TempSpot != NULL) {\r
+ *TempSpot = CHAR_NULL;\r
+ }\r
Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);\r
if (EFI_ERROR(Status)) {\r
FreePool(TempCopy);\r
Guid->Data1 = (UINT32)TempVal;\r
Walker += 9;\r
TempSpot = StrStr(Walker, L"-");\r
- *TempSpot = CHAR_NULL;\r
+ if (TempSpot != NULL) {\r
+ *TempSpot = CHAR_NULL;\r
+ }\r
Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);\r
if (EFI_ERROR(Status)) {\r
FreePool(TempCopy);\r
Guid->Data2 = (UINT16)TempVal;\r
Walker += 5;\r
TempSpot = StrStr(Walker, L"-");\r
- *TempSpot = CHAR_NULL;\r
+ if (TempSpot != NULL) {\r
+ *TempSpot = CHAR_NULL;\r
+ }\r
Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);\r
if (EFI_ERROR(Status)) {\r
FreePool(TempCopy);\r
FilePathSize = GetDevicePathSize (FilePath);\r
\r
TempByteBuffer = AllocateZeroPool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize);\r
- TempByteStart = TempByteBuffer;\r
- *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes\r
- TempByteBuffer += sizeof (UINT32);\r
+ if (TempByteBuffer != NULL) {\r
+ TempByteStart = TempByteBuffer;\r
+ *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes\r
+ TempByteBuffer += sizeof (UINT32);\r
\r
- *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength\r
- TempByteBuffer += sizeof (UINT16);\r
+ *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength\r
+ TempByteBuffer += sizeof (UINT16);\r
\r
- CopyMem (TempByteBuffer, Desc, DescSize);\r
- TempByteBuffer += DescSize;\r
- CopyMem (TempByteBuffer, FilePath, FilePathSize);\r
+ CopyMem (TempByteBuffer, Desc, DescSize);\r
+ TempByteBuffer += DescSize;\r
+ CopyMem (TempByteBuffer, FilePath, FilePathSize);\r
\r
- UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);\r
- Status = gRT->SetVariable (\r
- OptionStr,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
- TempByteStart\r
- );\r
-\r
- FreePool(TempByteStart);\r
+ UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);\r
+ Status = gRT->SetVariable (\r
+ OptionStr,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
+ TempByteStart\r
+ );\r
+\r
+ FreePool(TempByteStart);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellInstall1HiiHandle, OptionStr, Status);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0]));\r
- NewCount = OrderCount;\r
- CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
- for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){\r
- if (NewOrder[LoopVar] == Location) {\r
- CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));\r
- NewCount--;\r
+ if (NewOrder != NULL) {\r
+ NewCount = OrderCount;\r
+ CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
+ for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){\r
+ if (NewOrder[LoopVar] == Location) {\r
+ CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));\r
+ NewCount--;\r
+ }\r
}\r
+ Status = gRT->SetVariable(\r
+ Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
+ (EFI_GUID*)&gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
+ NewCount*sizeof(NewOrder[0]),\r
+ NewOrder);\r
+ FreePool(NewOrder);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
}\r
- Status = gRT->SetVariable(\r
- Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
- (EFI_GUID*)&gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
- NewCount*sizeof(NewOrder[0]),\r
- NewOrder);\r
- FreePool(NewOrder);\r
-\r
if (EFI_ERROR(Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellInstall1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status);\r
return (SHELL_INVALID_PARAMETER);\r
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);\r
\r
if (!Found) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"For", L"EndFor", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"For", \r
+ L"EndFor", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_NOT_FOUND);\r
}\r
return (SHELL_SUCCESS);\r
// Make sure that an End exists.\r
//\r
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"EndFor", \r
+ L"For", \r
+ CurrentScriptFile->CurrentCommand!=NULL\r
+ ?CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
// Check forwards and then backwards for a label...\r
//\r
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, CompareString, L"Goto", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ CompareString, \r
+ L"Goto", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
ShellStatus = SHELL_NOT_FOUND;\r
}\r
FreePool(CompareString);\r
// Make sure that an End exists.\r
//\r
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EnfIf", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"EnfIf", \r
+ L"If", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
\r
\r
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"If", \r
+ L"Else", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"If", \r
+ L"Else", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndIf", "Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"EndIf", \r
+ "Else", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
}\r
\r
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"EndIf", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"If", \r
+ L"EndIf", \r
+ ShellCommandGetCurrentScriptFile()!=NULL\r
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
//\r
if (Specific != NULL) {\r
NewSpecific = AllocateZeroPool(StrSize(Specific) + sizeof(CHAR16));\r
+ if (NewSpecific == NULL){\r
+ return FALSE;\r
+ }\r
StrCpy(NewSpecific, Specific);\r
if (NewSpecific[StrLen(NewSpecific)-1] != L':') {\r
StrCat(NewSpecific, L":");\r
// Get the map name(s) for each one.\r
//\r
for ( LoopVar = 0, Found = FALSE\r
- ; LoopVar < (BufferSize / sizeof(EFI_HANDLE))\r
+ ; LoopVar < (BufferSize / sizeof(EFI_HANDLE)) && HandleBuffer != NULL\r
; LoopVar ++\r
){\r
Status = PerformSingleMappingDisplay(\r
&BufferSize,\r
HandleBuffer);\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
- FreePool(HandleBuffer);\r
+ SHELL_FREE_NON_NULL(HandleBuffer);\r
HandleBuffer = AllocateZeroPool(BufferSize);\r
if (HandleBuffer == NULL) {\r
return (SHELL_OUT_OF_RESOURCES);\r
CHAR16 *NewSName;\r
\r
NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));\r
+ if (NewSName == NULL) {\r
+ return (SHELL_OUT_OF_RESOURCES);\r
+ }\r
StrCpy(NewSName, SName);\r
if (NewSName[StrLen(NewSName)-1] != L':') {\r
StrCat(NewSName, L":");\r
CHAR16 *NewSName;\r
\r
NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));\r
+ if (NewSName == NULL) {\r
+ return (SHELL_OUT_OF_RESOURCES);\r
+ }\r
StrCpy(NewSName, SName);\r
if (NewSName[StrLen(NewSName)-1] != L':') {\r
StrCat(NewSName, L":");\r
if (Walker1 != NULL) {\r
Walker = Walker1 + 1;\r
}\r
- Walker1 = StrStr(Walker, L"/");\r
+ Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;\r
if (Walker1 != NULL && *Walker1 == L'/') {\r
*Walker1 = CHAR_NULL;\r
}\r
if (Walker1 != NULL) {\r
Walker = Walker1 + 1;\r
}\r
- Walker1 = StrStr(Walker, L"/");\r
+ Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;\r
if (Walker1 != NULL && *Walker1 == L'/') {\r
*Walker1 = CHAR_NULL;\r
}\r
TheTime.Hour = 0xFF;\r
TheTime.Minute = 0xFF;\r
\r
- Walker2 = StrStr(Walker1, L":");\r
+ Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;\r
if (Walker2 != NULL && *Walker2 == L':') {\r
*Walker2 = CHAR_NULL;\r
}\r
if (Walker2 != NULL) {\r
Walker1 = Walker2 + 1;\r
}\r
- Walker2 = StrStr(Walker1, L":");\r
+ Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;\r
if (Walker2 != NULL && *Walker2 == L':') {\r
*Walker2 = CHAR_NULL;\r
}\r
SysInfo);\r
}\r
\r
+ ASSERT(SysInfo != NULL);\r
+\r
if (Delete) {\r
StrCpy ((CHAR16 *) SysInfo->VolumeLabel, L"");\r
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(SysInfo->VolumeLabel);\r
// Construct configuration request string header\r
//\r
ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
- Length = StrLen (ConfigHdr);\r
+ if (ConfigHdr != NULL) {\r
+ Length = StrLen (ConfigHdr);\r
+ } else {\r
+ Length = 0;\r
+ }\r
ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
if (ConfigResp == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_ERROR;\r
}\r
- StrCpy (ConfigResp, ConfigHdr);\r
+ if (ConfigHdr != NULL) {\r
+ StrCpy (ConfigResp, ConfigHdr);\r
+ }\r
\r
//\r
// Append OFFSET/WIDTH pair\r
// Construct config request string header\r
//\r
ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
-\r
- Length = StrLen (ConfigHdr);\r
+ if (ConfigHdr != NULL) {\r
+ Length = StrLen (ConfigHdr);\r
+ } else {\r
+ Length = 0;\r
+ }\r
ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
- StrCpy (ConfigResp, ConfigHdr);\r
+ if (ConfigHdr != NULL) {\r
+ StrCpy (ConfigResp, ConfigHdr);\r
+ }\r
\r
NicConfig = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
if (NicConfig == NULL) {\r
&HandleNum,\r
&HandleBuffer\r
);\r
- if (EFI_ERROR (Status) || (HandleNum == 0)) {\r
+ if (EFI_ERROR (Status) || (HandleNum == 0) || (HandleBuffer == NULL)) {\r
return EFI_ABORTED;\r
}\r
//\r