diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2021-10-04 16:04:41 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-11-03 23:43:46 +0000 |
commit | b258f12889c09555e99c9cebf56dba45190c5dc2 (patch) | |
tree | 9f973f0eb3d3ddfaaef12ceca66cd81be72d98d6 | |
parent | 6f9e83f757ed7c5c78d071f475b2e72d899c2aef (diff) | |
download | edk2-b258f12889c09555e99c9cebf56dba45190c5dc2.tar.gz |
BaseTools/VrfCompile: Fix uninitialized field from unnamed field
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3687
If a C structure parsed by the VFR compiler contains an unnamed
field, then mFieldName is left uninitialized, which generates
random data in the VFR compiler output file.
If the FieldName is NULL, then initialize pNewField->mFieldName
to a Null-terminated empty string.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index 2b9b5dbb1c..11470de45c 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -1135,6 +1135,8 @@ CVfrVarDataTypeDB::DataTypeAddBitField ( if (FieldName != NULL) {
strncpy (pNewField->mFieldName, FieldName, MAX_NAME_LEN - 1);
pNewField->mFieldName[MAX_NAME_LEN - 1] = 0;
+ } else {
+ strncpy (pNewField->mFieldName, "", MAX_NAME_LEN - 1);
}
pNewField->mFieldType = pFieldType;
pNewField->mIsBitField = TRUE;
@@ -3916,5 +3918,3 @@ CVfrStringDB::GetUnicodeStringTextSize ( CVfrVarDataTypeDB gCVfrVarDataTypeDB;
CVfrDefaultStore gCVfrDefaultStore;
CVfrDataStorage gCVfrDataStorage;
-
-
|