mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Merge pull request #8082 from SparkiDev/bn_bin2bn_fix
BN API: fix BN_bin2bn to handle NULL data properly
This commit is contained in:
@ -516,12 +516,14 @@ WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char* data, int len,
|
|||||||
ret = NULL;
|
ret = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Don't free bn as we may be returning it. */
|
/* Don't free bn as we are returning it. */
|
||||||
bn = NULL;
|
bn = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data == NULL) {
|
else if (data == NULL) {
|
||||||
wolfSSL_BN_zero(ret);
|
wolfSSL_BN_zero(ret);
|
||||||
|
/* Don't free bn as we are returning it. */
|
||||||
|
bn = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61624,6 +61624,11 @@ static int test_wolfSSL_BN_enc_dec(void)
|
|||||||
ExpectNull(BN_bn2dec(NULL));
|
ExpectNull(BN_bn2dec(NULL));
|
||||||
ExpectNull(BN_bn2dec(&emptyBN));
|
ExpectNull(BN_bn2dec(&emptyBN));
|
||||||
|
|
||||||
|
ExpectNotNull(c = BN_bin2bn(NULL, 0, NULL));
|
||||||
|
BN_clear(c);
|
||||||
|
BN_free(c);
|
||||||
|
c = NULL;
|
||||||
|
|
||||||
ExpectNotNull(BN_bin2bn(NULL, sizeof(binNum), a));
|
ExpectNotNull(BN_bin2bn(NULL, sizeof(binNum), a));
|
||||||
BN_free(a);
|
BN_free(a);
|
||||||
a = NULL;
|
a = NULL;
|
||||||
|
Reference in New Issue
Block a user