summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2016-10-11 10:06:50 +0800
committerHao Wu <hao.a.wu@intel.com>2016-11-08 16:36:12 +0800
commit02875ba228545f506cb40cfc8a20a4e067fb2a9f (patch)
tree3a6c2cffb24b296ecd56a879867d37ddabbe97df /BaseTools
parent2ff3293d7bdf32c5e7ab8728f2caa464e33eda0d (diff)
downloadedk2-02875ba228545f506cb40cfc8a20a4e067fb2a9f.zip
edk2-02875ba228545f506cb40cfc8a20a4e067fb2a9f.tar.gz
edk2-02875ba228545f506cb40cfc8a20a4e067fb2a9f.tar.bz2
BaseTools/EfiRom: 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>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/EfiRom/EfiRom.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c
index e2bd289..622a12f 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -1,7 +1,7 @@
/** @file
Utility program to create an EFI option ROM image from binary and EFI PE32 files.
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
@@ -95,24 +95,26 @@ Returns:
// the command line, or the first input filename with a different extension.
//
if (!mOptions.OutFileName[0]) {
- strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
- //
- // Find the last . on the line and replace the filename extension with
- // the default
- //
- for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
- (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
- Ext--
- )
- ;
- //
- // If dot here, then insert extension here, otherwise append
- //
- if (*Ext != '.') {
- Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
- }
+ if (mOptions.FileList != NULL) {
+ strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
+ //
+ // Find the last . on the line and replace the filename extension with
+ // the default
+ //
+ for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
+ (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
+ Ext--
+ )
+ ;
+ //
+ // If dot here, then insert extension here, otherwise append
+ //
+ if (*Ext != '.') {
+ Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
+ }
- strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
+ strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
+ }
}
//
// Make sure we don't have the same filename for input and output files