Skip to content

IntelFsp2Pkg/CacheLib: Make integer width consistent in loop condition #11025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

makubacki
Copy link
Member

Description

Explicitly casts mFixedMtrrTable[MsrNum].Length to resolve a comparison-with-wider-type CodeQL error.

https://codeql.github.com/codeql-query-help/cpp/cpp-comparison-with-wider-type/

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

How This Was Tested

  • CI
  • CodeQL against IntelFsp2Pkg

Integration Instructions

N/A

Explicitly casts `mFixedMtrrTable[MsrNum].Length` to resolve a
`comparison-with-wider-type` CodeQL error.

https://codeql.github.com/codeql-query-help/cpp/cpp-comparison-with-wider-type/

Signed-off-by: Michael Kubacki <[email protected]>
@@ -328,7 +328,7 @@ ProgramFixedMtrr (
return EFI_DEVICE_ERROR;
}

for ( ; ((ByteShift < 8) && (*Len >= mFixedMtrrTable[MsrNum].Length)); ByteShift++) {
for ( ; ((ByteShift < 8) && (*Len >= (UINT64)mFixedMtrrTable[MsrNum].Length)); ByteShift++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

enlarging the data type might bring some "unwanted data" into the "(UINT64) mFixedMtrrTable[MsrNum].Length"?
How about changing it like below which looks safer?

mFixedMtrrTable[MsrNum].Length <= (UINT32) *Len

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.

2 participants