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

index d2bf102bb9260c2fe8f282c173f4711f7a3d0384..0129e4eb3fb35590e96b0796108c8c42de84edf2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Creates output file that is a properly formed section per the PI spec.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -667,6 +667,10 @@ Returns:
     return Status;\r
   }\r
 \r
+  if (FileBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
   CompressFunction = NULL;\r
 \r
   //\r
@@ -731,6 +735,10 @@ Returns:
 \r
       return Status;\r
     }\r
+\r
+    if (FileBuffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
   DebugMsg (NULL, 0, 9, "comprss file size", \r
@@ -889,6 +897,10 @@ Returns:
     return Status;\r
   }\r
 \r
+  if (FileBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
   if (InputLength == 0) {\r
     Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);\r
     return EFI_NOT_FOUND;\r
@@ -1365,7 +1377,9 @@ Returns:
   //\r
   // GuidValue is only required by Guided section.\r
   //\r
-  if ((SectType != EFI_SECTION_GUID_DEFINED) && (CompareGuid (&VendorGuid, &mZeroGuid) != 0)) {\r
+  if ((SectType != EFI_SECTION_GUID_DEFINED) &&\r
+    (SectionName != NULL) &&\r
+    (CompareGuid (&VendorGuid, &mZeroGuid) != 0)) {\r
     fprintf (stdout, "Warning: the input guid value is not required for this section type %s\n", SectionName);\r
   }\r
   \r