For calls to API sprintf(), use hard-coded format string instead of a local variable.
This helps to prevent the format string from being changed accidentally, which may lead to potential buffer overflows. Cc: Liming Gao <liming....@intel.com> Cc: Yonghong Zhu <yonghong....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a...@intel.com> --- BaseTools/Source/C/VolInfo/VolInfo.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c index 5285acd..7ecfb7f 100644 --- a/BaseTools/Source/C/VolInfo/VolInfo.c +++ b/BaseTools/Source/C/VolInfo/VolInfo.c @@ -1599,7 +1599,6 @@ Returns: CHAR8 *ExtractionTool; CHAR8 *ToolInputFile; CHAR8 *ToolOutputFile; - CHAR8 *SystemCommandFormatString; CHAR8 *SystemCommand; EFI_GUID *EfiGuid; UINT16 DataOffset; @@ -1659,9 +1658,8 @@ Returns: SectionLength - SectionHeaderLen ); - SystemCommandFormatString = "%s sha1 -out %s %s"; SystemCommand = malloc ( - strlen (SystemCommandFormatString) + + strlen ("%s sha1 -out %s %s") + strlen (OpenSslPath) + strlen (ToolInputFileName) + strlen (ToolOutputFileName) + @@ -1673,7 +1671,7 @@ Returns: } sprintf ( SystemCommand, - SystemCommandFormatString, + "%s sha1 -out %s %s", OpenSslPath, ToolOutputFileName, ToolInputFileName @@ -1891,9 +1889,8 @@ Returns: // // Construction 'system' command string // - SystemCommandFormatString = "%s -d -o %s %s"; SystemCommand = malloc ( - strlen (SystemCommandFormatString) + + strlen ("%s -d -o %s %s") + strlen (ExtractionTool) + strlen (ToolInputFile) + strlen (ToolOutputFile) + @@ -1909,7 +1906,7 @@ Returns: } sprintf ( SystemCommand, - SystemCommandFormatString, + "%s -d -o %s %s", ExtractionTool, ToolOutputFile, ToolInputFile -- 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel