forked from wolfSSL/wolfssl
Fix for mp_radix_size
with radix 2 and mp_int equal to zero. Fix applies to normal and fast math only. ZD11419.
This commit is contained in:
@ -5256,7 +5256,10 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
|
|
||||||
/* special case for binary */
|
/* special case for binary */
|
||||||
if (radix == MP_RADIX_BIN) {
|
if (radix == MP_RADIX_BIN) {
|
||||||
*size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1;
|
*size = mp_count_bits(a);
|
||||||
|
if (*size == 0)
|
||||||
|
*size = 1;
|
||||||
|
*size += (a->sign == MP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5550,8 +5550,11 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
|
|
||||||
/* special case for binary */
|
/* special case for binary */
|
||||||
if (radix == 2) {
|
if (radix == 2) {
|
||||||
*size = fp_count_bits (a) + (a->sign == FP_NEG ? 1 : 0) + 1;
|
*size = fp_count_bits(a);
|
||||||
return FP_YES;
|
if (*size == 0)
|
||||||
|
*size = 1;
|
||||||
|
*size += (a->sign == FP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||||
|
return FP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure the radix is in range */
|
/* make sure the radix is in range */
|
||||||
|
Reference in New Issue
Block a user