From ae724571beb0cff6edefe42942b7cdc7aa81ee94 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Fri, 1 Apr 2011 22:16:01 +0000 Subject: 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 --- ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c | 2 +- ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib') diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c index e7d19c9bed..68130d4db8 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c @@ -650,7 +650,7 @@ PerformMappingDisplay( &BufferSize, HandleBuffer); } - if (!EFI_ERROR(Status)) { + if (!EFI_ERROR(Status) && HandleBuffer != NULL) { // // Get the map name(s) for each one. // diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c index 53b7770dfe..51cf33f1ba 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c @@ -30,7 +30,7 @@ EFIAPI HandleVol( IN CONST CHAR16 *Path, IN CONST BOOLEAN Delete, - IN CONST CHAR16 *Name + IN CONST CHAR16 *Name OPTIONAL ) { EFI_STATUS Status; @@ -45,6 +45,7 @@ HandleVol( ShellStatus = SHELL_SUCCESS; if ( + Name != 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 ) ){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Name); return (SHELL_INVALID_PARAMETER); @@ -150,6 +151,8 @@ HandleVol( } gEfiShellProtocol->CloseFile(ShellFileHandle); + + ASSERT(SysInfo != NULL); // // print VolumeInfo table @@ -200,6 +203,7 @@ ShellCommandRunVol ( CHAR16 *FullPath; CHAR16 *TempSpot; UINTN Length; + CONST CHAR16 *NewName; Length = 0; ProblemParam = NULL; @@ -266,20 +270,21 @@ ShellCommandRunVol ( StrnCatGrow(&FullPath, &Length, PathName, 0); StrnCatGrow(&FullPath, &Length, L":\\", 0); DeleteMode = ShellCommandLineGetFlag(Package, L"-d"); + NewName = ShellCommandLineGetValue(Package, L"-n"); if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle); 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"); 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"); ShellStatus = SHELL_INVALID_PARAMETER; } else if (ShellStatus == SHELL_SUCCESS) { ShellStatus = HandleVol( FullPath, DeleteMode, - ShellCommandLineGetValue(Package, L"-n") + NewName ); } } -- cgit v1.2.3