mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #6133 from philljj/zd15662
Fix malloc of zero size in fast_s_mp_sqr and fast_s_mp_mul_digs.
This commit is contained in:
@@ -3335,6 +3335,12 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
|
|||||||
if (pa > (int)MP_WARRAY)
|
if (pa > (int)MP_WARRAY)
|
||||||
return MP_RANGE; /* TAO range check */
|
return MP_RANGE; /* TAO range check */
|
||||||
|
|
||||||
|
if (pa == 0) {
|
||||||
|
/* Nothing to do. Zero result and return. */
|
||||||
|
mp_zero(b);
|
||||||
|
return MP_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
||||||
if (W == NULL)
|
if (W == NULL)
|
||||||
@@ -3454,6 +3460,12 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
|||||||
if (pa > (int)MP_WARRAY)
|
if (pa > (int)MP_WARRAY)
|
||||||
return MP_RANGE; /* TAO range check */
|
return MP_RANGE; /* TAO range check */
|
||||||
|
|
||||||
|
if (pa == 0) {
|
||||||
|
/* Nothing to do. Zero result and return. */
|
||||||
|
mp_zero(c);
|
||||||
|
return MP_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
||||||
if (W == NULL)
|
if (W == NULL)
|
||||||
|
Reference in New Issue
Block a user