diff options
author | Hao Wu <hao.a.wu@intel.com> | 2018-09-28 20:12:23 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2018-10-18 09:12:38 +0800 |
commit | ebb12f514287696ed916d722a03eb49e7cab2ff0 (patch) | |
tree | 7e60c715790ca04bd42f4f28989cc49f66337a5d | |
parent | 3a0329bed2a2c7d1ba45bd2376a2320141ef2bec (diff) | |
download | edk2-ebb12f514287696ed916d722a03eb49e7cab2ff0.tar.gz edk2-ebb12f514287696ed916d722a03eb49e7cab2ff0.tar.bz2 edk2-ebb12f514287696ed916d722a03eb49e7cab2ff0.zip |
MdeModulePkg/UdfDxe: Use error handling for memory allocation failure
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1247
For functions DuplicateFid() and DuplicateFe(), this commit will use error
handling logic instead of ASSERTs for memory allocation failure.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
-rw-r--r-- | MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index ecc172303e..638f31bd82 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -468,8 +468,6 @@ DuplicateFid ( *NewFileIdentifierDesc =
(UDF_FILE_IDENTIFIER_DESCRIPTOR *)AllocateCopyPool (
(UINTN) GetFidDescriptorLength (FileIdentifierDesc), FileIdentifierDesc);
-
- ASSERT (*NewFileIdentifierDesc != NULL);
}
/**
@@ -490,8 +488,6 @@ DuplicateFe ( )
{
*NewFileEntry = AllocateCopyPool (Volume->FileEntrySize, FileEntry);
-
- ASSERT (*NewFileEntry != NULL);
}
/**
@@ -1370,7 +1366,15 @@ InternalFindFile ( }
DuplicateFe (BlockIo, Volume, Parent->FileEntry, &File->FileEntry);
+ if (File->FileEntry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
DuplicateFid (Parent->FileIdentifierDesc, &File->FileIdentifierDesc);
+ if (File->FileIdentifierDesc == NULL) {
+ FreePool (File->FileEntry);
+ return EFI_OUT_OF_RESOURCES;
+ }
return EFI_SUCCESS;
}
@@ -1732,9 +1736,20 @@ FindFile ( // We've already a file pointer (Root) for the root directory. Duplicate
// its FE/EFE and FID descriptors.
//
- DuplicateFe (BlockIo, Volume, Root->FileEntry, &File->FileEntry);
- DuplicateFid (Root->FileIdentifierDesc, &File->FileIdentifierDesc);
Status = EFI_SUCCESS;
+ DuplicateFe (BlockIo, Volume, Root->FileEntry, &File->FileEntry);
+ if (File->FileEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ //
+ // File->FileEntry is not NULL.
+ //
+ DuplicateFid (Root->FileIdentifierDesc, &File->FileIdentifierDesc);
+ if (File->FileIdentifierDesc == NULL) {
+ FreePool (File->FileEntry);
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
}
} else {
//
@@ -1874,6 +1889,9 @@ ReadDirectoryEntry ( } while (FileIdentifierDesc->FileCharacteristics & DELETED_FILE);
DuplicateFid (FileIdentifierDesc, FoundFid);
+ if (*FoundFid == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
return EFI_SUCCESS;
}
@@ -2031,8 +2049,18 @@ ResolveSymlink ( // "." (current file). Duplicate both FE/EFE and FID of this file.
//
DuplicateFe (BlockIo, Volume, PreviousFile.FileEntry, &File->FileEntry);
+ if (File->FileEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error_Find_File;
+ }
+
DuplicateFid (PreviousFile.FileIdentifierDesc,
&File->FileIdentifierDesc);
+ if (File->FileIdentifierDesc == NULL) {
+ FreePool (File->FileEntry);
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error_Find_File;
+ }
goto Next_Path_Component;
case 5:
//
|