diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-10-11 10:25:34 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-11-08 16:36:30 +0800 |
commit | 90114c101f2149ec02f7ba66af78addc2d72cb2e (patch) | |
tree | d071b405244fae2ff24c84d064dabb81d6b8c745 | |
parent | 248fce0329c1bfdfa9486e357e40a911361003bd (diff) | |
download | edk2-platforms-90114c101f2149ec02f7ba66af78addc2d72cb2e.tar.xz |
BaseTools/GenVtf: Avoid possible NULL pointer dereference
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r-- | BaseTools/Source/C/GenVtf/GenVtf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index f6765ddbca..b68d86a97e 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1125,6 +1125,7 @@ Returns: EFI_ABORTED - Aborted due to one of the many reasons like:
(a) Component Size greater than the specified size.
(b) Error opening files.
+ (c) Fail to get the FIT table address.
EFI_INVALID_PARAMETER Value returned from call to UpdateEntryPoint()
EFI_OUT_OF_RESOURCES Memory allocation failure.
@@ -1240,6 +1241,10 @@ Returns: }
GetNextAvailableFitPtr (&CompFitPtr);
+ if (CompFitPtr == NULL) {
+ free (Buffer);
+ return EFI_ABORTED;
+ }
CompFitPtr->CompAddress = CompStartAddress | IPF_CACHE_BIT;
if ((FileSize % 16) != 0) {
@@ -2652,6 +2657,7 @@ Returns: }
SymFileName = VTF_SYM_FILE;
} else {
+ assert (OutFileName1);
INTN OutFileNameLen = strlen(OutFileName1);
INTN NewIndex;
@@ -2665,6 +2671,10 @@ Returns: } else {
INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE);
SymFileName = malloc(SymFileNameLen + 1);
+ if (SymFileName == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ goto ERROR;
+ }
memcpy(SymFileName, OutFileName1, NewIndex + 1);
memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE));
SymFileName[SymFileNameLen] = '\0';
|