Comment's added and fixed.

Pointer's checked for NULL before access and after memory allocations.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11499 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey 2011-04-01 22:16:01 +00:00
parent 5f2915f593
commit ae724571be
19 changed files with 481 additions and 518 deletions

View File

@ -1547,7 +1547,7 @@ FileInterfaceFileGetInfo(
/** /**
Set information about a file Set information about a file
@param File Protocol instance pointer. @param This Protocol instance pointer.
@param InformationType Type of information in Buffer. @param InformationType Type of information in Buffer.
@param BufferSize Size of buffer. @param BufferSize Size of buffer.
@param Buffer The data to write. @param Buffer The data to write.

View File

@ -415,6 +415,14 @@ CleanUpShellParametersProtocol (
return (Status); return (Status);
} }
/**
Determin if a file name represents a unicode file.
@param[in] FileName Pointer to the filename to open.
@retval EFI_SUCCESS The file is a unicode file.
@return An error upon failure.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
IsUnicodeFile( IsUnicodeFile(

View File

@ -1191,7 +1191,7 @@ ShellPromptForResponse (
to prevent invalid answers to question. to prevent invalid answers to question.
@param[in] HiiFormatStringId The format string Id for getting from Hii. @param[in] HiiFormatStringId The format string Id for getting from Hii.
@param[in] HiiFormatHandle The format string Handle for getting from Hii. @param[in] HiiFormatHandle The format string Handle for getting from Hii.
@param[out] Response The pointer to Response, which will be populated upon return. @param[in,out] Response The pointer to Response, which will be populated upon return.
@retval EFI_SUCCESS The operation was sucessful. @retval EFI_SUCCESS The operation was sucessful.
@return other The operation failed. @return other The operation failed.

View File

@ -15,7 +15,7 @@
#ifndef __SHELL_BASE__ #ifndef __SHELL_BASE__
#define __SHELL_BASE__ #define __SHELL_BASE__
#define ABS(a) (a<0)?(-(a)):(a) #define ABS(a) ((a<0)?(-(a)):(a))
typedef VOID *SHELL_FILE_HANDLE; typedef VOID *SHELL_FILE_HANDLE;

View File

@ -237,8 +237,7 @@ FreeMemory (
} }
/** /**
Initialize String Info Log data structures Initialize String Info Log data structures.
**/ **/
VOID VOID
EFIAPI EFIAPI
@ -1043,8 +1042,7 @@ WritePTLen (
} }
/** /**
Outputs the code length array for Char&Length Set Outputs the code length array for Char&Length Set.
**/ **/
VOID VOID
EFIAPI EFIAPI

View File

@ -357,7 +357,7 @@ FileBufferRestoreMousePosition (
CurrentLine = FileBuffer.CurrentLine; CurrentLine = FileBuffer.CurrentLine;
Line = MoveLine (FRow - FileBuffer.FilePosition.Row); Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
if (FColumn > Line->Size) { if (Line == NULL || FColumn > Line->Size) {
HasCharacter = FALSE; HasCharacter = FALSE;
} }
@ -1367,7 +1367,7 @@ GetNewLine (
Change a Unicode string to an ASCII string. Change a Unicode string to an ASCII string.
@param[in] UStr The Unicode string. @param[in] UStr The Unicode string.
@param[in] Lenght The maximum size of AStr. @param[in] Length The maximum size of AStr.
@param[out] AStr ASCII string to pass out. @param[out] AStr ASCII string to pass out.
@return The actuall length. @return The actuall length.
@ -1375,9 +1375,9 @@ GetNewLine (
UINTN UINTN
EFIAPI EFIAPI
UnicodeToAscii ( UnicodeToAscii (
IN CONST CHAR16 *UStr, IN CONST CHAR16 *UStr,
IN CONST UINTN Length, IN CONST UINTN Length,
OUT CHAR8 *AStr OUT CHAR8 *AStr
) )
{ {
UINTN Index; UINTN Index;
@ -1621,7 +1621,7 @@ FileBufferSave (
// //
// now everything is ready , you can set the new file name to filebuffer // now everything is ready , you can set the new file name to filebuffer
// //
if (StrCmp (FileName, FileBuffer.FileName) != 0) { if (FileName != NULL && FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) != 0) {
// //
// not the same // not the same
// //

View File

@ -91,7 +91,7 @@ MainCommandSearch (
VOID VOID
); );
/* /**
search string in file buffer, and replace it with another str search string in file buffer, and replace it with another str
@retval EFI_SUCCESS The operation was successful. @retval EFI_SUCCESS The operation was successful.
@ -589,8 +589,8 @@ MainCommandSearch (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/* /**
search string in file buffer, and replace it with another str Search string in file buffer, and replace it with another str.
@retval EFI_SUCCESS The operation was successful. @retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed. @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@ -1589,7 +1589,6 @@ GetTextY (
@retval EFI_SUCCESS The operation was successful. @retval EFI_SUCCESS The operation was successful.
@retval EFI_NOT_FOUND There was no mouse support found. @retval EFI_NOT_FOUND There was no mouse support found.
**/ **/
STATIC
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
MainEditorHandleMouseInput ( MainEditorHandleMouseInput (

View File

@ -188,10 +188,15 @@ HBufferImageReplace (
UINTN UINTN
); );
/**
Free the current image.
@retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS EFI_STATUS
HBufferImageFree ( HBufferImageFree (
VOID VOID
) ; );
EFI_STATUS EFI_STATUS
HBufferImageDeleteCharacterFromBuffer ( HBufferImageDeleteCharacterFromBuffer (

View File

@ -489,7 +489,8 @@ Returns:
// //
// now everything is ready , you can set the new file name to filebuffer // now everything is ready , you can set the new file name to filebuffer
// //
if (BufferTypeBackup != FileTypeFileBuffer || StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0) { if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||
(FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){
// //
// not the same // not the same
// //

View File

@ -135,8 +135,8 @@ ShellCommandRunHexEdit (
Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2)); Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
} }
} }
if (WhatToDo == FileTypeNone && ShellCommandLineGetRawValue(Package, 1) != NULL) { Name = ShellCommandLineGetRawValue(Package, 1);
Name = ShellCommandLineGetRawValue(Package, 1); if (WhatToDo == FileTypeNone && Name != NULL) {
if (!IsValidFileName(Name)) { if (!IsValidFileName(Name)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;

View File

@ -1868,9 +1868,9 @@ Returns:
|| ReadChange ) { || ReadChange ) {
MainTitleBarRefresh ( MainTitleBarRefresh (
HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL, HMainEditor.BufferImage->BufferType == FileTypeFileBuffer&&HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Name:NULL,
HMainEditor.BufferImage->BufferType, HMainEditor.BufferImage->BufferType,
HMainEditor.BufferImage->FileImage->ReadOnly, (BOOLEAN)(HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->ReadOnly:FALSE),
HMainEditor.BufferImage->Modified, HMainEditor.BufferImage->Modified,
HMainEditor.ScreenSize.Column, HMainEditor.ScreenSize.Column,
HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Row,

View File

@ -2969,7 +2969,7 @@ QueryTable (
// //
if (High > Low && Key >= Low && Key <= High) { if (High > Low && Key >= Low && Key <= High) {
StrnCpy (Info, Table[Index].Info, InfoLen-1); StrnCpy (Info, Table[Index].Info, InfoLen-1);
StrCat (Info, L"\n"); StrnCat (Info, L"\n", InfoLen - StrLen(Info));
return Key; return Key;
} }
// //
@ -2977,7 +2977,7 @@ QueryTable (
// //
if (Table[Index].Key == Key) { if (Table[Index].Key == Key) {
StrnCpy (Info, Table[Index].Info, InfoLen-1); StrnCpy (Info, Table[Index].Info, InfoLen-1);
StrCat (Info, L"\n"); StrnCat (Info, L"\n", InfoLen - StrLen(Info));
return Key; return Key;
} }
} }

View File

@ -69,6 +69,7 @@ ShellCommandRunEndFor (
{ {
EFI_STATUS Status; EFI_STATUS Status;
BOOLEAN Found; BOOLEAN Found;
SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit(); Status = CommandInit();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
@ -86,6 +87,7 @@ ShellCommandRunEndFor (
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE); Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
if (!Found) { if (!Found) {
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -94,9 +96,9 @@ ShellCommandRunEndFor (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"For", L"For",
L"EndFor", L"EndFor",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_NOT_FOUND); return (SHELL_NOT_FOUND);
} }
return (SHELL_SUCCESS); return (SHELL_SUCCESS);
@ -421,7 +423,16 @@ ShellCommandRunFor (
Info->CurrentValue = NULL; Info->CurrentValue = NULL;
ArgSetWalker = ArgSet; ArgSetWalker = ArgSet;
if (ArgSetWalker[0] != L'(') { if (ArgSetWalker[0] != L'(') {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
TempSpot = StrStr(ArgSetWalker, L")"); TempSpot = StrStr(ArgSetWalker, L")");
@ -437,7 +448,15 @@ ShellCommandRunFor (
} }
} }
if (TempSpot == NULL) { if (TempSpot == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
*TempSpot = CHAR_NULL; *TempSpot = CHAR_NULL;
@ -446,7 +465,16 @@ ShellCommandRunFor (
ArgSetWalker++; ArgSetWalker++;
} }
if (!ShellIsValidForNumber(ArgSetWalker)) { if (!ShellIsValidForNumber(ArgSetWalker)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (ArgSetWalker[0] == L'-') { if (ArgSetWalker[0] == L'-') {
@ -459,7 +487,16 @@ ShellCommandRunFor (
ArgSetWalker++; ArgSetWalker++;
} }
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (ArgSetWalker[0] == L'-') { if (ArgSetWalker[0] == L'-') {
@ -479,7 +516,16 @@ ShellCommandRunFor (
} }
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) { if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (*ArgSetWalker == L')') { if (*ArgSetWalker == L')') {
@ -492,7 +538,16 @@ ShellCommandRunFor (
} }
if (StrStr(ArgSetWalker, L" ") != NULL) { if (StrStr(ArgSetWalker, L" ") != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
} }
@ -512,7 +567,16 @@ ShellCommandRunFor (
} }
CurrentScriptFile->CurrentCommand->Data = Info; CurrentScriptFile->CurrentCommand->Data = Info;
} else { } else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
gShellLevel1HiiHandle,
ArgSet,
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
} else { } else {
@ -553,7 +617,17 @@ ShellCommandRunFor (
// find the matching endfor (we're done with the loop) // find the matching endfor (we're done with the loop)
// //
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) { if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
gShellLevel1HiiHandle,
L"EndFor",
L"For",
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR; ShellStatus = SHELL_DEVICE_ERROR;
} }
if (Info->RemoveSubstAlias) { if (Info->RemoveSubstAlias) {
@ -611,7 +685,17 @@ ShellCommandRunFor (
// find the matching endfor (we're done with the loop) // find the matching endfor (we're done with the loop)
// //
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) { if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
gShellLevel1HiiHandle,
L"EndFor",
L"For",
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR; ShellStatus = SHELL_DEVICE_ERROR;
} }
if (Info->RemoveSubstAlias) { if (Info->RemoveSubstAlias) {

View File

@ -33,6 +33,7 @@ ShellCommandRunGoto (
SHELL_STATUS ShellStatus; SHELL_STATUS ShellStatus;
CHAR16 *CompareString; CHAR16 *CompareString;
UINTN Size; UINTN Size;
SCRIPT_FILE *CurrentScriptFile;
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
CompareString = NULL; CompareString = NULL;
@ -79,6 +80,7 @@ ShellCommandRunGoto (
// Check forwards and then backwards for a label... // Check forwards and then backwards for a label...
// //
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) { if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -87,9 +89,9 @@ ShellCommandRunGoto (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
CompareString, CompareString,
L"Goto", L"Goto",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} }
FreePool(CompareString); FreePool(CompareString);

View File

@ -825,7 +825,7 @@ ShellCommandRunIf (
BOOLEAN CurrentValue; BOOLEAN CurrentValue;
END_TAG_TYPE Ending; END_TAG_TYPE Ending;
END_TAG_TYPE PreviousEnding; END_TAG_TYPE PreviousEnding;
SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit(); Status = CommandInit();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
@ -843,7 +843,8 @@ ShellCommandRunIf (
// //
// Make sure that an End exists. // Make sure that an End exists.
// //
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) { CurrentScriptFile = ShellCommandGetCurrentScriptFile();
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -852,9 +853,9 @@ ShellCommandRunIf (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"EnfIf", L"EnfIf",
L"If", L"If",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }
@ -928,7 +929,18 @@ ShellCommandRunIf (
// build up the next statement for analysis // build up the next statement for analysis
// //
if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) { if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"Then", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line); CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
gShellLevel1HiiHandle,
L"Then",
L"If",
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
// //
@ -979,6 +991,7 @@ ShellCommandRunElse (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit()); ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) { if (gEfiShellParametersProtocol->Argc > 1) {
@ -991,8 +1004,9 @@ ShellCommandRunElse (
return (SHELL_UNSUPPORTED); return (SHELL_UNSUPPORTED);
} }
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) { if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -1001,12 +1015,12 @@ ShellCommandRunElse (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"If", L"If",
L"Else", L"Else",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }
if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) { if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -1015,13 +1029,13 @@ ShellCommandRunElse (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"If", L"If",
L"Else", L"Else",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) { if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -1030,9 +1044,9 @@ ShellCommandRunElse (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"EndIf", L"EndIf",
"Else", "Else",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }
@ -1052,6 +1066,7 @@ ShellCommandRunEndIf (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit()); ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) { if (gEfiShellParametersProtocol->Argc > 1) {
@ -1064,7 +1079,8 @@ ShellCommandRunEndIf (
return (SHELL_UNSUPPORTED); return (SHELL_UNSUPPORTED);
} }
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) { CurrentScriptFile = ShellCommandGetCurrentScriptFile();
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx( ShellPrintHiiEx(
-1, -1,
-1, -1,
@ -1073,9 +1089,9 @@ ShellCommandRunEndIf (
gShellLevel1HiiHandle, gShellLevel1HiiHandle,
L"If", L"If",
L"EndIf", L"EndIf",
ShellCommandGetCurrentScriptFile()!=NULL CurrentScriptFile!=NULL
&&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL && CurrentScriptFile->CurrentCommand!=NULL
?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0); ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }

View File

@ -650,7 +650,7 @@ PerformMappingDisplay(
&BufferSize, &BufferSize,
HandleBuffer); HandleBuffer);
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status) && HandleBuffer != NULL) {
// //
// Get the map name(s) for each one. // Get the map name(s) for each one.
// //

View File

@ -30,7 +30,7 @@ EFIAPI
HandleVol( HandleVol(
IN CONST CHAR16 *Path, IN CONST CHAR16 *Path,
IN CONST BOOLEAN Delete, IN CONST BOOLEAN Delete,
IN CONST CHAR16 *Name IN CONST CHAR16 *Name OPTIONAL
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -45,6 +45,7 @@ HandleVol(
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
if ( if (
Name != NULL && (
StrStr(Name, L"%") != NULL || StrStr(Name, L"%") != NULL ||
StrStr(Name, L"^") != NULL || StrStr(Name, L"^") != NULL ||
StrStr(Name, L"*") != NULL || StrStr(Name, L"*") != NULL ||
@ -60,7 +61,7 @@ HandleVol(
StrStr(Name, L">") != NULL || StrStr(Name, L">") != NULL ||
StrStr(Name, L"?") != NULL || StrStr(Name, L"?") != NULL ||
StrStr(Name, L"/") != NULL || StrStr(Name, L"/") != NULL ||
StrStr(Name, L" ") != NULL StrStr(Name, L" ") != NULL )
){ ){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Name); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Name);
return (SHELL_INVALID_PARAMETER); return (SHELL_INVALID_PARAMETER);
@ -150,6 +151,8 @@ HandleVol(
} }
gEfiShellProtocol->CloseFile(ShellFileHandle); gEfiShellProtocol->CloseFile(ShellFileHandle);
ASSERT(SysInfo != NULL);
// //
// print VolumeInfo table // print VolumeInfo table
@ -200,6 +203,7 @@ ShellCommandRunVol (
CHAR16 *FullPath; CHAR16 *FullPath;
CHAR16 *TempSpot; CHAR16 *TempSpot;
UINTN Length; UINTN Length;
CONST CHAR16 *NewName;
Length = 0; Length = 0;
ProblemParam = NULL; ProblemParam = NULL;
@ -266,20 +270,21 @@ ShellCommandRunVol (
StrnCatGrow(&FullPath, &Length, PathName, 0); StrnCatGrow(&FullPath, &Length, PathName, 0);
StrnCatGrow(&FullPath, &Length, L":\\", 0); StrnCatGrow(&FullPath, &Length, L":\\", 0);
DeleteMode = ShellCommandLineGetFlag(Package, L"-d"); DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
NewName = ShellCommandLineGetValue(Package, L"-n");
if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) { if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag(Package, L"-n") && ShellCommandLineGetValue(Package, L"-n") == NULL) { } else if (ShellCommandLineGetFlag(Package, L"-n") && NewName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-n"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetValue(Package, L"-n") != NULL && StrLen(ShellCommandLineGetValue(Package, L"-n")) > 11) { } else if (NewName != NULL && StrLen(NewName) > 11) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-n"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellStatus == SHELL_SUCCESS) { } else if (ShellStatus == SHELL_SUCCESS) {
ShellStatus = HandleVol( ShellStatus = HandleVol(
FullPath, FullPath,
DeleteMode, DeleteMode,
ShellCommandLineGetValue(Package, L"-n") NewName
); );
} }
} }

View File

@ -781,9 +781,14 @@ IfconfigSetNicAddrByHii (
if (ConfigHdr != NULL) { if (ConfigHdr != NULL) {
Length = StrLen (ConfigHdr); Length = StrLen (ConfigHdr);
} else { } else {
Length = 0; ShellStatus = SHELL_OUT_OF_RESOURCES;
goto ON_EXIT;
} }
ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16)); ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
if (ConfigResp == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto ON_EXIT;
}
if (ConfigHdr != NULL) { if (ConfigHdr != NULL) {
StrCpy (ConfigResp, ConfigHdr); StrCpy (ConfigResp, ConfigHdr);
} }