Skip to content

Conversation

@makubacki
Copy link
Collaborator

@makubacki makubacki commented Nov 27, 2025

Description

Fixes #1127

Code is currently commented out in test_fv_functionality() that calls fv_read_file() with a non-null buffer and buffer size of zero.

This change updates fv_read_file() to follow the same behavior as the C DXE Core FvReadFile() function in FwVolRead.c that will return BUFFER_TOO_SMALL in this scenario.

Another difference in behavior is that if the caller provides a non-null buffer but a buffer size less than the file content size, the C implementation will truncate the copy size to the size provided and perform the copy with that size. To prevent further discrepancies between caller expectations, that change is made in a second commit.


patina_dxe_core: Truncate copies in fv_read_file()

Matches the C implementation more closely by performing truncated copies
when the provided buffer is too small.


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

How This Was Tested

  • cargo make all

Integration Instructions

  • N/A

@makubacki makubacki self-assigned this Nov 27, 2025
@github-actions github-actions bot added the impact:testing Affects testing label Nov 27, 2025
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
patina_dxe_core/src/fv.rs 84.62% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@makubacki makubacki force-pushed the fix_fv_zero_buf_test branch from 6c53ac4 to 9fb2aff Compare November 27, 2025 01:10
@makubacki makubacki changed the title patina_dxe_core/fv: Fix test_fv_functionality() panic patina_dxe_core/fv: Fix test_fv_functionality() panic [Rebase & FF] Dec 1, 2025
@makubacki makubacki marked this pull request as ready for review December 1, 2025 16:39
@Javagedes
Copy link
Collaborator

Javagedes commented Dec 1, 2025

Wow you did this fast. I was expecting this be worked on after #1121 was merged, as it does a lot of moving of files around, and would still prefer that #1121 goes in before this.

But I can deal with the merge conflict if you want to get this in before that. The change itself looks good to me.

Copy link
Contributor

@os-d os-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The first commit message says it isn't going to follow the C behavior because it is unintuitive but then the second commit adds that behavior. May be worth amending the commit message.

@makubacki
Copy link
Collaborator Author

nit: The first commit message says it isn't going to follow the C behavior because it is unintuitive but then the second commit adds that behavior. May be worth amending the commit message.

That reflects my decision process :). I decided to just get it to match to prevent dealing with some subtle difference in the future. I'll update the commit message.

Fixes OpenDevicePartnership#1127

Code is currently commented out in `test_fv_functionality()` that
calls `fv_read_file()` with a non-null buffer and buffer size of
zero.

This change updates `fv_read_file()` to follow the same behavior
as the C DXE Core `FvReadFile()` function in FwVolRead.c that will
return `BUFFER_TOO_SMALL` in this scenario.

Another difference in behavior is that if the caller provides a
non-null buffer but a buffer size less than the file content size,
the C implementation will truncate the copy size to the size provided
and perform the copy with that size. That change is made in a separate
commit.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Matches the C implementation more closely by performing truncated copies
when the provided buffer is too small.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki makubacki force-pushed the fix_fv_zero_buf_test branch from 634b6c3 to 7264ce3 Compare December 1, 2025 17:04
@makubacki makubacki enabled auto-merge (rebase) December 1, 2025 17:08
@makubacki makubacki merged commit 2d10867 into OpenDevicePartnership:main Dec 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:testing Affects testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: panic in fv.rs test case

4 participants