diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-04 21:41:24 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-04 21:41:24 +0000 |
commit | cbdd109b43c8386d74a7bb40d892e5c2485f71f9 (patch) | |
tree | 55cecf05db45228dae0f65785412b3eb7ce537a7 | |
parent | 4aa4377fdab7a01995b2f32e2a96c8340531cb6e (diff) | |
download | edk2-cbdd109b43c8386d74a7bb40d892e5c2485f71f9.zip edk2-cbdd109b43c8386d74a7bb40d892e5c2485f71f9.tar.gz edk2-cbdd109b43c8386d74a7bb40d892e5c2485f71f9.tar.bz2 |
check memory allocations for success.
check pointer before access.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11503 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 2 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c | 21 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 4 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni | bin | 111056 -> 111268 bytes | |||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c | 54 |
5 files changed, 48 insertions, 33 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c index 8223847..8f7c870 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -2760,7 +2760,7 @@ FileBufferMovePosition ( //
FileBuffer.FilePosition.Column = NewFilePosCol;
if (ColGap < 0) {
- Abs = -ColGap;
+ Abs = (UINTN)(-ColGap);
FileBuffer.DisplayPosition.Column -= Abs;
} else {
FileBuffer.DisplayPosition.Column += ColGap;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c index afccf7b..34eb6af 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c @@ -205,15 +205,20 @@ ShellCommandRunSetVar ( Data++;
Data++;
Buffer = AllocateZeroPool(StrSize(Data));
- UnicodeSPrint(Buffer, StrSize(Data), L"%s", Data);
- ((CHAR16*)Buffer)[StrLen(Buffer)-1] = CHAR_NULL;
-
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrSize(Buffer)-sizeof(CHAR16), Buffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status);
- ShellStatus = SHELL_ACCESS_DENIED;
+ if (Buffer == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle);
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
+ UnicodeSPrint(Buffer, StrSize(Data), L"%s", Data);
+ ((CHAR16*)Buffer)[StrLen(Buffer)-1] = CHAR_NULL;
+
+ Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrSize(Buffer)-sizeof(CHAR16), Buffer);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status);
+ ShellStatus = SHELL_ACCESS_DENIED;
+ } else {
+ ASSERT(ShellStatus == SHELL_SUCCESS);
+ }
}
} else if (StrnCmp(Data, L"--", 2) == 0) {
//
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index 6411009..b8e4805 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -565,7 +565,9 @@ ShellCommandRunFor ( Info->RemoveSubstAlias = TRUE;
}
}
- CurrentScriptFile->CurrentCommand->Data = Info;
+ if (CurrentScriptFile->CurrentCommand != NULL) {
+ CurrentScriptFile->CurrentCommand->Data = Info;
+ }
} else {
ShellPrintHiiEx(
-1,
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni Binary files differindex f9c1181..428d8dd 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c index 51cf33f..9300d5e 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c @@ -113,14 +113,20 @@ HandleVol( Size2 = StrSize(SysInfo->VolumeLabel);
if (Size1 > Size2) {
SysInfo = ReallocatePool((UINTN)SysInfo->Size, (UINTN)SysInfo->Size + Size1 - Size2, SysInfo);
+ if (SysInfo == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle);
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ }
+ }
+ if (SysInfo != NULL) {
+ StrCpy ((CHAR16 *) SysInfo->VolumeLabel, Name);
+ SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
+ Status = EfiFpHandle->SetInfo(
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ (UINTN)SysInfo->Size,
+ SysInfo);
}
- StrCpy ((CHAR16 *) SysInfo->VolumeLabel, Name);
- SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
- Status = EfiFpHandle->SetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- (UINTN)SysInfo->Size,
- SysInfo);
}
FreePool(SysInfo);
@@ -154,22 +160,24 @@ HandleVol( ASSERT(SysInfo != NULL);
- //
- // print VolumeInfo table
- //
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_VOL_VOLINFO),
- gShellLevel2HiiHandle,
- SysInfo->VolumeLabel,
- SysInfo->ReadOnly?L"r":L"rw",
- SysInfo->VolumeSize,
- SysInfo->FreeSpace,
- SysInfo->BlockSize
- );
- SHELL_FREE_NON_NULL(SysInfo);
+ if (SysInfo != NULL) {
+ //
+ // print VolumeInfo table
+ //
+ ShellPrintHiiEx (
+ 0,
+ gST->ConOut->Mode->CursorRow,
+ NULL,
+ STRING_TOKEN (STR_VOL_VOLINFO),
+ gShellLevel2HiiHandle,
+ SysInfo->VolumeLabel,
+ SysInfo->ReadOnly?L"r":L"rw",
+ SysInfo->VolumeSize,
+ SysInfo->FreeSpace,
+ SysInfo->BlockSize
+ );
+ SHELL_FREE_NON_NULL(SysInfo);
+ }
return (ShellStatus);
}
|