Skip to content

Conversation

@mikebeaton
Copy link
Member

See individual commit messages.

Prefer to rebase and merge not squash and merge when okay, to preserve commit messages. Can do.

mBitWidth is accessed for non-bitfield structures with bitfield
children, when traversing down through nested fields in
GetDataFieldInfo. Thus it is read uninitialized in this case, and
needs to be zeroed. This can be caught using sanitizers.

Signed-off-by: Mike Beaton <[email protected]>
This structure was of size 23, but needs to be a multiple of 4 in
order not to cause unaligned access errors in VfrCompile, which
can be seen using ASan.

Signed-off-by: Mike Beaton <[email protected]>
@mikebeaton
Copy link
Member Author

cf tianocore/edk2#11777

@mikebeaton mikebeaton changed the title Fix VfrCompile bugs! Fix VfrCompile bugs Nov 21, 2025
@mikebeaton mikebeaton marked this pull request as draft November 21, 2025 09:06
@mikebeaton
Copy link
Member Author

Draft while I streamline the fixed bit logic, as suggested by @mhaeuser.

The previous logic for accessing bit fields is wrong when the bit field
starts beyond the first byte, in a storage unit larger than a byte.

This caused unaligned memory accesses which can be caught
by sanitizers.

We also bump the tool minor version number to reflect a functional bugfix.

Signed-off-by: Mike Beaton <[email protected]>
…nal types

Internal types such as pFormIdField, pFormSetGuidField have
no associated field type, however the Dump command assumes
that all types do. This causes null pointer dereferencing which
can be caught by sanitizers.

De facto, the field type for these types was already
dumped as <null>, this achieves the same safely.

Signed-off-by: Mike Beaton <[email protected]>
Add minor code cleanups made while tracking down the bugs fixed in the
preceding commits.

 - Fix spelling 'arrary' -> 'array' where it occurs in the tool code and comments.
   - When renaming ExtractFieldNameAndArrary to ExtractFieldNameAndArrayIdx,
we fix the typo and also clarify what the method does: it returns the field name
and the array index when present. Since it is always used to populate a local
variable named ArrayIdx, we stick to that spelling in the renamed method.
 - Add comment clarifying that mArrayNum holds array length (but again, don't
go for a bigger global rename).
 - Rename CVfrVarDataTypeDB::GetFieldWidth to GetFieldType. It is only used
once, and the new name correctly matches what it does.

Signed-off-by: Mike Beaton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant