From 8994aab0ed83a2d58da2c5bff1f16c346551f018 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 17 Apr 2023 10:09:02 +1000 Subject: [PATCH] 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. --- wolfcrypt/src/sp_int.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 571e3a897..7b999cd10 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -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); }