mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Fix out-of-bounds write in fp_mod_2d.
This commit is contained in:
@ -1010,6 +1010,13 @@ void fp_mod_2d(fp_int *a, int b, fp_int *c)
|
||||
}
|
||||
|
||||
bmax = ((unsigned int)b + DIGIT_BIT - 1) / DIGIT_BIT;
|
||||
|
||||
/* If a is negative and bmax is larger than FP_SIZE, then the
|
||||
* result can't fit within c. Just return. */
|
||||
if (c->sign == FP_NEG && bmax > FP_SIZE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* zero digits above the last digit of the modulus */
|
||||
for (x = bmax; x < (unsigned int)c->used; x++) {
|
||||
c->dp[x] = 0;
|
||||
|
Reference in New Issue
Block a user