-
Notifications
You must be signed in to change notification settings - Fork 121
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
Adding unsigned int sanitization and SCRUTINICE fixes #2103
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2103 +/- ##
==========================================
- Coverage 78.76% 78.74% -0.02%
==========================================
Files 598 598
Lines 103656 103656
Branches 14720 14719 -1
==========================================
- Hits 81641 81624 -17
- Misses 21363 21379 +16
- Partials 652 653 +1 ☔ View full report in Codecov by Sentry. |
long callback_ret = bio->callback_ex(bio, oper, buf, len, 0, 0L, ret, &processed); | ||
if (callback_ret <= INT_MAX) { | ||
ret = (int)callback_ret; | ||
if (ret > 0) { | ||
// BIO will only read int |len| bytes so this is a safe cast | ||
ret = (int)processed; | ||
} |
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.
callback_ret
might also be less thanINT_MIN
. (We do a similar check on line 139 below.)
if (callback_ret <= INT_MAX && callback_ret >= INT_MIN) {
ret = (int)callback_ret;
- If
callback_ret
is not in this range we're simply not setting it (i.e., there's noelse
block), but that doesn't seem right. What value do we set it to? Maybe-1
?
if (ret <= 0 && ret >= INT_MIN) { | ||
return (int)ret; |
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.
- If
ret <= 0
, the function should return even ifret < INT_MIN
. Maybe returnINT_MIN
?
if (ret <= 0) {
if (ret >= INT_MIN) {
return (int)ret;
} else {
return INT_MIN;
}
}
- Ditto for the numerous similar changes below in this file.
@@ -448,7 +448,7 @@ BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out) { | |||
} | |||
out->neg = ((*in) & 0x80) != 0; | |||
if (out->neg) { | |||
BN_clear_bit(out, BN_num_bits(out) - 1); | |||
BN_clear_bit(out, (int)BN_num_bits(out) - 1); |
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.
NP: Should we verify that (BN_num_bits(out) - 1) <= INT_MAX
?
@@ -85,12 +85,10 @@ void CRYPTO_cbc128_encrypt(const uint8_t *in, uint8_t *out, size_t len, | |||
} | |||
(*block)(out, out, key); | |||
iv = out; | |||
// This will always be true as a result of the first while loop |
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.
Then we should instead change the while (len)
above to an if (len > 0)
and then there's no reason to break
.
Issues:
Description of changes:
Call-outs:
Point out areas that need special attention or support during the review process. Discuss architecture or design changes.
Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.