summaryrefslogtreecommitdiff
path: root/edk2/ShellPkg/Application
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-10 20:32:17 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-10 20:32:17 +0000
commit90b78a0ffe5f23e6657e8554c4e967c5ce2f2904 (patch)
tree67513edbd27e998610e72ffce8eeff2dfb878beb /edk2/ShellPkg/Application
parent3623e045ef0075ebc9c8b96d28120cb53a0159c1 (diff)
ShellPkg: Add checks for NULL pointers.
This adds lots of pointer verification with ASSERTs only used when the condition should be impossible and never for memory allocation. signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@12523 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/ShellPkg/Application')
-rw-r--r--edk2/ShellPkg/Application/Shell/FileHandleWrappers.c6
-rw-r--r--edk2/ShellPkg/Application/Shell/ShellManParser.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/edk2/ShellPkg/Application/Shell/FileHandleWrappers.c b/edk2/ShellPkg/Application/Shell/FileHandleWrappers.c
index 2e1ce08ef..2ca13cb3f 100644
--- a/edk2/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/edk2/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -1327,7 +1327,8 @@ FileInterfaceMemGetPosition(
@param[in, out] BufferSize Size in bytes of Buffer.
@param[in] Buffer The pointer to the buffer to write.
- @retval EFI_SUCCESS The data was written.
+ @retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.
+ @retval EFI_SUCCESS The data was written.
**/
EFI_STATUS
EFIAPI
@@ -1354,6 +1355,9 @@ FileInterfaceMemWrite(
// Ascii
//
AsciiBuffer = AllocateZeroPool(*BufferSize);
+ if (AsciiBuffer == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);
diff --git a/edk2/ShellPkg/Application/Shell/ShellManParser.c b/edk2/ShellPkg/Application/Shell/ShellManParser.c
index bcc1f8e0a..bd2efcb42 100644
--- a/edk2/ShellPkg/Application/Shell/ShellManParser.c
+++ b/edk2/ShellPkg/Application/Shell/ShellManParser.c
@@ -548,7 +548,8 @@ ManFileFindTitleSection(
@retval EFI_SUCCESS The help text was returned.
@retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the
returned help text.
- @retval EFI_INVALID_PARAMETER HelpText is NULL
+ @retval EFI_INVALID_PARAMETER HelpText is NULL.
+ @retval EFI_INVALID_PARAMETER ManFileName is invalid.
@retval EFI_NOT_FOUND There is no help text available for Command.
**/
EFI_STATUS
@@ -594,6 +595,9 @@ ProcessManFile(
} else {
FileHandle = NULL;
TempString = GetManFileName(ManFileName);
+ if (TempString == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
Status = SearchPathForFile(TempString, &FileHandle);
if (EFI_ERROR(Status)) {