When modifying the Optional Data of a boot option with bcfg boot -opt the result was corrupted data, for instance a concatenation of old data, heap contents, and new data. This was due to a erronous calculation of the original optional data length.
In addition to fixing the calculation, add explaining comments and introduce a helper variable, to not abuse other variables and confuse readers (including the author).
Tagging it "security" because the bug can potentially be used for OOB access.
[ ] Breaking change?
Breaking change - Does this PR cause a break in build or boot behavior?
Examples: Does it add a new library class or move a module to a different repo.
[x] Impacts security?
Security - Does this PR have a direct security impact?
Examples: Crypto algorithm change or buffer overflow fix.
[ ] Includes tests?
Tests - Does this PR include any explicit test code?
Description
When modifying the Optional Data of a boot option with bcfg boot -opt the result was corrupted data, for instance a concatenation of old data, heap contents, and new data. This was due to a erronous calculation of the original optional data length.
In addition to fixing the calculation, add explaining comments and introduce a helper variable, to not abuse other variables and confuse readers (including the author).
Tagging it "security" because the bug can potentially be used for OOB access.
How This Was Tested
Before:
After:
Integration Instructions
N/A