Fix overflow in fp_to_unsigned_bin_len length check. (#6075)
* Fix overflow in fp_to_unsigned_bin_len length check. * Add a second check when i == a->used - 1.
This commit is contained in:
parent
c2384674d8
commit
5b8fda1ac6
@ -3834,7 +3834,10 @@ int fp_to_unsigned_bin_len(fp_int *a, unsigned char *b, int c)
|
||||
for (; x >= 0; x--) {
|
||||
b[x] = 0;
|
||||
}
|
||||
if ((i < a->used - 1) || ((a->dp[i] >> j) != 0)) {
|
||||
if (i < a->used - 1) {
|
||||
return FP_VAL;
|
||||
}
|
||||
if ((i == a->used - 1) && ((a->dp[i] >> j) != 0)) {
|
||||
return FP_VAL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user