From 03bc7c2b09c6f36930a5138c7727c0c4048539a7 Mon Sep 17 00:00:00 2001 From: Shumin Qiu Date: Thu, 9 Jan 2014 00:30:27 +0000 Subject: [PATCH] Add code to check whether the pointer 'NewBuffer' in 'FileHandelWrappers.c' and the pointer 'FoundVarName' in 'Dmpstore.c' are NULL before used. Signed-off-by: Shumin Qiu Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15060 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/FileHandleWrappers.c | 4 ++-- .../Library/UefiShellDebug1CommandsLib/DmpStore.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index ef8293c1de..c67ddfc269 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -2,7 +2,7 @@ EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables, StdIn, StdOut, StdErr, etc...). - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
Copyright (c) 2013, Hewlett-Packard Development Company, L.P. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -973,7 +973,7 @@ FileInterfaceEnvClose( Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer); } - if (!EFI_ERROR(Status)) { + if (!EFI_ERROR(Status) && NewBuffer != NULL) { if (StrSize(NewBuffer) > 6) { diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c index afeedb0959..b02048302e 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -121,11 +121,15 @@ CascadeProcessVariables ( if (Status == EFI_BUFFER_TOO_SMALL) { SHELL_FREE_NON_NULL(FoundVarName); FoundVarName = AllocateZeroPool (NameSize); - if (PrevName != NULL) { - StrCpy(FoundVarName, PrevName); - } + if (FoundVarName != NULL) { + if (PrevName != NULL) { + StrCpy(FoundVarName, PrevName); + } - Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); + Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); + } else { + Status = EFI_OUT_OF_RESOURCES; + } } // -- 2.39.2