forked from wolfSSL/wolfssl
SP int: sp_radix_size when radix 10 fix temp size
SP int should be able to calculate size of encoded number for a radix of 10 when mp_int has all digits used. sp_radix_size declared a temporary mp_int of 1 greater than input. Don't need it 1 greater. Stack declaration of maximum plus one caused address sanitizer error. Changed temporary mp_int to be same size as input mp_int.
This commit is contained in:
@ -17825,12 +17825,12 @@ int sp_radix_size(const sp_int* a, int radix, int* size)
|
||||
*size = 1 + 1;
|
||||
}
|
||||
else {
|
||||
DECL_SP_INT(t, a->used + 1);
|
||||
DECL_SP_INT(t, a->used);
|
||||
|
||||
/* Temporary to be divided by 10. */
|
||||
ALLOC_SP_INT(t, a->used + 1, err, NULL);
|
||||
ALLOC_SP_INT(t, a->used, err, NULL);
|
||||
if (err == MP_OKAY) {
|
||||
t->size = a->used + 1;
|
||||
t->size = a->used;
|
||||
err = sp_copy(a, t);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user