]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenVtf: Avoid possible NULL pointer dereference
authorHao Wu <hao.a.wu@intel.com>
Tue, 11 Oct 2016 02:25:34 +0000 (10:25 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 8 Nov 2016 08:36:30 +0000 (16:36 +0800)
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>
BaseTools/Source/C/GenVtf/GenVtf.c

index f6765ddbcaba8bc3d20a6c313e217f04bc765152..b68d86a97eb935a16760237d0cb83e2a0378a245 100644 (file)
@@ -1125,6 +1125,7 @@ Returns:
   EFI_ABORTED      - Aborted due to one of the many reasons like:\r
                       (a) Component Size greater than the specified size.\r
                       (b) Error opening files.\r
+                      (c) Fail to get the FIT table address.\r
 \r
   EFI_INVALID_PARAMETER     Value returned from call to UpdateEntryPoint()\r
   EFI_OUT_OF_RESOURCES      Memory allocation failure.\r
@@ -1240,6 +1241,10 @@ Returns:
   }\r
 \r
   GetNextAvailableFitPtr (&CompFitPtr);\r
+  if (CompFitPtr == NULL) {\r
+    free (Buffer);\r
+    return EFI_ABORTED;\r
+  }\r
 \r
   CompFitPtr->CompAddress = CompStartAddress | IPF_CACHE_BIT;\r
   if ((FileSize % 16) != 0) {\r
@@ -2652,6 +2657,7 @@ Returns:
     }\r
     SymFileName = VTF_SYM_FILE;\r
   } else {\r
+    assert (OutFileName1);\r
     INTN OutFileNameLen = strlen(OutFileName1);\r
     INTN NewIndex;\r
 \r
@@ -2665,6 +2671,10 @@ Returns:
     } else {\r
       INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE);\r
       SymFileName = malloc(SymFileNameLen + 1);\r
+      if (SymFileName == NULL) {\r
+        Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+        goto ERROR;\r
+      }\r
       memcpy(SymFileName, OutFileName1, NewIndex + 1);\r
       memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE));\r
       SymFileName[SymFileNameLen] = '\0';\r