* [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field
@ 2021-11-01 17:44 Michael D Kinney
2021-11-02 1:19 ` 回复: " gaoliming
2021-11-02 5:10 ` Bob Feng
0 siblings, 2 replies; 3+ messages in thread
From: Michael D Kinney @ 2021-11-01 17:44 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen
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>
---
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 2b9b5dbb1ca5..11470de45cce 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;
-
-
--
2.32.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* 回复: [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field
2021-11-01 17:44 [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field Michael D Kinney
@ 2021-11-02 1:19 ` gaoliming
2021-11-02 5:10 ` Bob Feng
1 sibling, 0 replies; 3+ messages in thread
From: gaoliming @ 2021-11-02 1:19 UTC (permalink / raw)
To: 'Michael D Kinney', devel
Cc: 'Bob Feng', 'Yuwei Chen'
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> -----邮件原件-----
> 发件人: Michael D Kinney <michael.d.kinney@intel.com>
> 发送时间: 2021年11月2日 1:45
> 收件人: devel@edk2.groups.io
> 抄送: Bob Feng <bob.c.feng@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Yuwei Chen <yuwei.chen@intel.com>
> 主题: [Patch 1/1] 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>
> ---
> BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index 2b9b5dbb1ca5..11470de45cce 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;
> -
> -
> --
> 2.32.0.windows.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field
2021-11-01 17:44 [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field Michael D Kinney
2021-11-02 1:19 ` 回复: " gaoliming
@ 2021-11-02 5:10 ` Bob Feng
1 sibling, 0 replies; 3+ messages in thread
From: Bob Feng @ 2021-11-02 5:10 UTC (permalink / raw)
To: Kinney, Michael D, devel@edk2.groups.io; +Cc: Liming Gao, Chen, Christine
This patch is good to me.
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Tuesday, November 2, 2021 1:45 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
Subject: [Patch 1/1] 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>
---
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 2b9b5dbb1ca5..11470de45cce 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;
-
-
--
2.32.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-02 5:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-01 17:44 [Patch 1/1] BaseTools/VrfCompile: Fix uninitialized field from unnamed field Michael D Kinney
2021-11-02 1:19 ` 回复: " gaoliming
2021-11-02 5:10 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox