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>
This commit is contained in:
		
				
					committed by
					
						![mergify[bot]](/avatar/e3df20cd7a67969c41a65f03bea54961?size=40) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							6f9e83f757
						
					
				
				
					commit
					b258f12889
				
			| @@ -1135,6 +1135,8 @@ CVfrVarDataTypeDB::DataTypeAddBitField ( | |||||||
|   if (FieldName != NULL) { |   if (FieldName != NULL) { | ||||||
|     strncpy (pNewField->mFieldName, FieldName, MAX_NAME_LEN - 1); |     strncpy (pNewField->mFieldName, FieldName, MAX_NAME_LEN - 1); | ||||||
|     pNewField->mFieldName[MAX_NAME_LEN - 1] = 0; |     pNewField->mFieldName[MAX_NAME_LEN - 1] = 0; | ||||||
|  |   } else { | ||||||
|  |     strncpy (pNewField->mFieldName, "", MAX_NAME_LEN - 1); | ||||||
|   } |   } | ||||||
|   pNewField->mFieldType    = pFieldType; |   pNewField->mFieldType    = pFieldType; | ||||||
|   pNewField->mIsBitField   = TRUE; |   pNewField->mIsBitField   = TRUE; | ||||||
| @@ -3916,5 +3918,3 @@ CVfrStringDB::GetUnicodeStringTextSize ( | |||||||
| CVfrVarDataTypeDB gCVfrVarDataTypeDB; | CVfrVarDataTypeDB gCVfrVarDataTypeDB; | ||||||
| CVfrDefaultStore  gCVfrDefaultStore; | CVfrDefaultStore  gCVfrDefaultStore; | ||||||
| CVfrDataStorage  gCVfrDataStorage; | CVfrDataStorage  gCVfrDataStorage; | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user