diff options
author | Dandan Bi <dandan.bi@intel.com> | 2017-07-11 15:35:14 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-08-04 14:32:42 +0800 |
commit | 8c1e13d327e6c0409435edaa89b909fbdef49232 (patch) | |
tree | fd2027a4d741cf199ebeca806739cb738674887b | |
parent | 41c9011cc166cff8a27a7e90592d81ba570b42ff (diff) | |
download | edk2-8c1e13d327e6c0409435edaa89b909fbdef49232.tar.gz edk2-8c1e13d327e6c0409435edaa89b909fbdef49232.tar.bz2 edk2-8c1e13d327e6c0409435edaa89b909fbdef49232.zip |
BaseTools/VfrCompile: Fix segmentation fault issues
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=532
(1) Add NULL check before using a pointer.
(2) Use "%s" format string in DebugError function to
avoid crash caused by incorrect input.
Cc: Bo Chen <chenbo@pdx.edu>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp index ff7057a64f..e65a92534f 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -642,7 +642,7 @@ CVfrCompiler::PreProcess ( }
if ((pVfrFile = fopen (LongFilePath (mOptions.VfrFileName), "r")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening the input VFR file", mOptions.VfrFileName);
+ DebugError (NULL, 0, 0001, "Error opening the input VFR file", "%s", mOptions.VfrFileName);
goto Fail;
}
fclose (pVfrFile);
@@ -711,7 +711,7 @@ CVfrCompiler::Compile ( gCVfrErrorHandle.SetWarningAsError(mOptions.WarningAsError);
if ((pInFile = fopen (LongFilePath (InFileName), "r")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening the input file", InFileName);
+ DebugError (NULL, 0, 0001, "Error opening the input file", "%s", InFileName);
goto Fail;
}
@@ -841,7 +841,7 @@ CVfrCompiler::GenBinary ( if (mOptions.CreateIfrPkgFile == TRUE) {
if ((pFile = fopen (LongFilePath (mOptions.PkgOutputFileName), "wb")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);
+ DebugError (NULL, 0, 0001, "Error opening file", "%s", mOptions.PkgOutputFileName);
goto Fail;
}
if (gCFormPkg.BuildPkg (pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {
@@ -884,7 +884,7 @@ CVfrCompiler::GenCFile ( if (!mOptions.CreateIfrPkgFile || mOptions.CompatibleMode) {
if ((pFile = fopen (LongFilePath (mOptions.COutputFileName), "w")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
+ DebugError (NULL, 0, 0001, "Error opening output C file", "%s", mOptions.COutputFileName);
goto Fail;
}
@@ -925,18 +925,18 @@ CVfrCompiler::GenRecordListFile ( InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
- if (mOptions.CreateRecordListFile == TRUE) {
+ if (mOptions.CreateRecordListFile == TRUE && InFileName != NULL && mOptions.RecordListFile != NULL) {
if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
return;
}
if ((pInFile = fopen (LongFilePath (InFileName), "r")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName);
+ DebugError (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", "%s", InFileName);
return;
}
if ((pOutFile = fopen (LongFilePath (mOptions.RecordListFile), "w")) == NULL) {
- DebugError (NULL, 0, 0001, "Error opening the record list file", mOptions.RecordListFile);
+ DebugError (NULL, 0, 0001, "Error opening the record list file", "%s", mOptions.RecordListFile);
goto Err1;
}
|