mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
Fix possible use of ForceZero with NULL pointer. Improve init of "kb" when small stack disabled, so memset isn't performed twice.
This commit is contained in:
@@ -4326,7 +4326,7 @@ static int accel_fp_mul2add(int idx1, int idx2,
|
|||||||
#define KB_SIZE 128
|
#define KB_SIZE 128
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
unsigned char* kb[2];
|
unsigned char* kb[2] = {NULL, NULL};
|
||||||
#else
|
#else
|
||||||
unsigned char kb[2][KB_SIZE];
|
unsigned char kb[2][KB_SIZE];
|
||||||
#endif
|
#endif
|
||||||
@@ -4337,8 +4337,6 @@ static int accel_fp_mul2add(int idx1, int idx2,
|
|||||||
if (mp_init_multi(&tka, &tkb, &order, NULL, NULL, NULL) != MP_OKAY)
|
if (mp_init_multi(&tka, &tkb, &order, NULL, NULL, NULL) != MP_OKAY)
|
||||||
return MP_INIT_E;
|
return MP_INIT_E;
|
||||||
|
|
||||||
XMEMSET(kb, 0, sizeof(kb));
|
|
||||||
|
|
||||||
/* if it's smaller than modulus we fine */
|
/* if it's smaller than modulus we fine */
|
||||||
if (mp_unsigned_bin_size(kA) > mp_unsigned_bin_size(modulus)) {
|
if (mp_unsigned_bin_size(kA) > mp_unsigned_bin_size(modulus)) {
|
||||||
/* find order */
|
/* find order */
|
||||||
@@ -4526,8 +4524,10 @@ done:
|
|||||||
mp_clear(&order);
|
mp_clear(&order);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ForceZero(kb[0], KB_SIZE);
|
if (kb[0])
|
||||||
ForceZero(kb[1], KB_SIZE);
|
ForceZero(kb[0], KB_SIZE);
|
||||||
|
if (kb[1])
|
||||||
|
ForceZero(kb[1], KB_SIZE);
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(kb[0], NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(kb[0], NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
Reference in New Issue
Block a user