Closed yeggor closed 2 years ago
Also, I think it makes sense to add a check here: https://github.com/LongSoft/UEFITool/blob/5f134f783ad6d1e1cf58fc1133d40e64840b5950/common/nvramparser.cpp#L1051
Yeah, that NVRAM parser is in a dire need of Kaitai treatment, i.e. getting replaced by an autogenerated parser based on KS DSL.
I'll merge the PR once CI is done.
It would definitely be great to have for NVRAM what you did with BootGuard/ACM related structures.
This PR fixes UINT32 underflow in
NvramParser::parseEvsaStoreBody
. The issue occurs here: https://github.com/LongSoft/UEFITool/blob/5f134f783ad6d1e1cf58fc1133d40e64840b5950/common/nvramparser.cpp#L1716calculateChecksum8
function takes as its second parameter aUINT32 bufferSize
. Thus, ifentryHeader->Size
is 0 or 1, bufferSize will becomeMAX_UINT32
or(MAX_UINT32 - 1)
.This will lead to OOB access inside
calculateChecksum8
and segfault:To fix this, I added an additional check here: https://github.com/LongSoft/UEFITool/blob/5f134f783ad6d1e1cf58fc1133d40e64840b5950/common/nvramparser.cpp#L1696
Just in case, I am attaching several files that cause this problem. uefitool_crash.zip