summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C/EfiRom
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2017-12-18 09:16:00 +0800
committerHao Wu <hao.a.wu@intel.com>2017-12-25 09:54:22 +0800
commit52e8c5683843f3d5f9e979cbc0261d3951a7e0be (patch)
tree7851d614bfb836cd54f3b6a03009fc07de9f9e84 /BaseTools/Source/C/EfiRom
parent3e1497334e45d09b8eccbc24ca571308e015e995 (diff)
downloadedk2-52e8c5683843f3d5f9e979cbc0261d3951a7e0be.zip
edk2-52e8c5683843f3d5f9e979cbc0261d3951a7e0be.tar.gz
edk2-52e8c5683843f3d5f9e979cbc0261d3951a7e0be.tar.bz2
BaseTools/EfiRom: Add/refine boundary checks for strcpy/strcat calls
Add checks to ensure when the destination string buffer is of fixed size, the strcpy/strcat functions calls will not access beyond the boundary. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/C/EfiRom')
-rw-r--r--BaseTools/Source/C/EfiRom/EfiRom.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c
index 6648f4c..fc3b5ad 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -96,7 +96,13 @@ Returns:
//
if (!mOptions.OutFileName[0]) {
if (mOptions.FileList != NULL) {
- strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
+ if (strlen (mOptions.FileList->FileName) >= MAX_PATH) {
+ Status = STATUS_ERROR;
+ Error (NULL, 0, 2000, "Invalid parameter", "Input file name is too long - %s.", mOptions.FileList->FileName);
+ goto BailOut;
+ }
+ strncpy (mOptions.OutFileName, mOptions.FileList->FileName, MAX_PATH - 1);
+ mOptions.OutFileName[MAX_PATH - 1] = 0;
//
// Find the last . on the line and replace the filename extension with
// the default