-
Notifications
You must be signed in to change notification settings - Fork 67
Avoid invalid gcc 14.3 warning about array bounds in mbedtls_xor #73
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
Conversation
tomi-font
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rather first make a PR in upstream Mbed TLS and then cherry pick it here?
|
|
Thanks! If you want to get this merged here before it's merged upstream then please add a reference to the upstream PR (e.g. PR #) in the commit message. Otherwise we can just wait and cherry pick the upstream commit (with |
It's blocking SDK version 0.18, so we should probably not wait (the fix is pretty easy to review in isolation). |
tomi-font
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe align this with Mbed-TLS/mbedtls#10318 and then we can merge this PR?
2c49239 to
a8466a6
Compare
tomi-font
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now missing the upstream PR # in the commit message 🙃
The combination of the multi-byte loop with the single byte loop confuses GCC 14.3's array bounds checker. When the loop size is constant, check to see if it is a multiple of the multi-byte size and bail early. As this will be evaluated at compile time, there should be no run-time cost. This change uses the __builtin_constant_p compile-time operation. To check if that is supported, the change uses the existing MBEDTLS_HAS_BUILTIN macro. That macro was defined later in library/common.h than is needed for this change, so it was moved up to join some other macros that looked similar. Upstream PR: Mbed-TLS/mbedtls#10318 Signed-off-by: Keith Packard <keithp@keithp.com>
a8466a6 to
75bc123
Compare
The combination of the multi-byte loop with the single byte loop confuses GCC 14.3's array bounds checker. When the loop size is constant, check to see if it is a multiple of the multi-byte size and bail early. As this will be evaluated at compile time, there should be no run-time cost.