-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Backport 2.28: Fix undefined behavior in bignum: NULL+0 and -most-negative-sint #6618
Backport 2.28: Fix undefined behavior in bignum: NULL+0 and -most-negative-sint #6618
Conversation
Since they're part of the public API (even if only through a few functions), they should be documented. I deliberately skipped documenting how to configure the size of the type. Right now, MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 have no Doxygen documentation, so it's ambiguous whether they're part of the public API. Resolving this ambiguity is out of scope of my current work. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Fix undefined behavior (typically harmless in practice) of mbedtls_mpi_add_mpi(), mbedtls_mpi_add_abs() and mbedtls_mpi_add_int() when both operands are 0 and the left operand is represented with 0 limbs. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
When x is the most negative value of a two's complement type, `(unsigned_type)(-x)` has undefined behavior, whereas `-(unsigned_type)x` has well-defined behavior and does what was intended. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
/** \typedef mbedtls_mpi_sint | ||
* \brief The signed type corresponding to #mbedtls_mpi_uint. | ||
* | ||
* This is always an signed integer type with no padding bits. The size |
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.
Grr, missed this in the original. Up to you whether you fix :)
* This is always an signed integer type with no padding bits. The size | |
* This is always a signed integer type with no padding bits. The size |
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.
This hinders neither comprehension nor grepping so I'd prefer to merge if the CI is happy.
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.
I gave an approval anyway...
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.
Faithful backport
Marking |
Fix two kinds of typically harmless undefined behavior in bignum. Trivial backport of #6609.
Gatekeeper checklist