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

index e2bd28960227625c65332f7068011533ca0775c7..622a12f04d89bda05630f2be433d59450cb99d2e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility program to create an EFI option ROM image from binary and EFI PE32 files.\r
 \r
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available \r
 under the terms and conditions of the BSD License which accompanies this \r
 distribution.  The full text of the license may be found at\r
@@ -95,24 +95,26 @@ Returns:
   // the command line, or the first input filename with a different extension.\r
   //\r
   if (!mOptions.OutFileName[0]) {\r
-    strcpy (mOptions.OutFileName, mOptions.FileList->FileName);\r
-    //\r
-    // Find the last . on the line and replace the filename extension with\r
-    // the default\r
-    //\r
-    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
-         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
-         Ext--\r
-        )\r
-      ;\r
-    //\r
-    // If dot here, then insert extension here, otherwise append\r
-    //\r
-    if (*Ext != '.') {\r
-      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
-    }\r
+    if (mOptions.FileList != NULL) {\r
+      strcpy (mOptions.OutFileName, mOptions.FileList->FileName);\r
+      //\r
+      // Find the last . on the line and replace the filename extension with\r
+      // the default\r
+      //\r
+      for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
+           (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
+           Ext--\r
+          )\r
+        ;\r
+      //\r
+      // If dot here, then insert extension here, otherwise append\r
+      //\r
+      if (*Ext != '.') {\r
+        Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
+      }\r
 \r
-    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
+      strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
+    }\r
   }\r
   //\r
   // Make sure we don't have the same filename for input and output files\r