Skip to content

MdeModulePkg/ImagePropertiesRecordLib: Fix incorrect use of sizeof#12880

Open
szsam wants to merge 1 commit into
tianocore:masterfrom
szsam:fix/imageproperties-getfilename-size
Open

MdeModulePkg/ImagePropertiesRecordLib: Fix incorrect use of sizeof#12880
szsam wants to merge 1 commit into
tianocore:masterfrom
szsam:fix/imageproperties-getfilename-size

Conversation

@szsam

@szsam szsam commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

In GetFilename(), the post-loop fallback termination used sizeof (EfiFileName), which is the size of the CHAR8 * pointer parameter (8 bytes on X64), not the buffer size. Use EfiFileNameSize - 4 to match the bound of the copy loop above so the string is terminated at the true end of the buffer.

  • Breaking change?
  • Impacts security?
  • Includes tests?

How This Was Tested

Tested on OvmfPkgIa32X64, DEBUG, GCC: DumpImageRecords() prints all runtime image names correctly and NUL-terminated, with no ASSERTs.

Integration Instructions

N/A

In GetFilename(), the post-loop fallback termination used
sizeof (EfiFileName), which is the size of the CHAR8 * pointer
parameter (8 bytes on X64), not the buffer size. Use EfiFileNameSize -
4 to match the bound of the copy loop above so the string is
terminated at the true end of the buffer.

Tested on OvmfPkgIa32X64, DEBUG, GCC: DumpImageRecords() prints all
runtime image names correctly and NUL-terminated, with no ASSERTs.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant