Fix for bug in `wolfSSL_EC_POINT_free` not freeing the internal ECC point. Unit test fixup for `test_wolfSSL_EVP_PKEY_new_mac_key` with malloc and size 0. Cleanup the EC_POINT unit test to not set `Gxy->inSet`, since its already 0.

pull/1204/head
David Garske 2017-11-01 09:22:04 -07:00
parent 72a33136f5
commit cc7a5fd490
3 changed files with 9 additions and 11 deletions

View File

@ -22040,9 +22040,8 @@ void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *p)
WOLFSSL_ENTER("wolfSSL_EC_POINT_free");
if (p != NULL) {
if (p->internal == NULL) {
if (p->internal != NULL) {
wc_ecc_del_point((ecc_point*)p->internal);
XFREE(p->internal, NULL, DYNAMIC_TYPE_ECC);
p->internal = NULL;
}

View File

@ -775,7 +775,6 @@ static void test_wolfSSL_EC(void)
Gxy->X = Gx;
Gxy->Y = Gy;
Gxy->Z = Gz;
Gxy->inSet = 0;
/* perform point multiplication */
AssertIntEQ(EC_POINT_mul(group, new_point, NULL, Gxy, k, ctx), WOLFSSL_SUCCESS);
@ -9759,9 +9758,9 @@ static void test_wolfSSL_EVP_PKEY_new_mac_key(void)
#ifdef OPENSSL_EXTRA
static const unsigned char pw[] = "password";
static const int pwSz = sizeof(pw) - 1;
size_t checkPwSz;
const unsigned char* checkPw;
WOLFSSL_EVP_PKEY* key;
size_t checkPwSz = 0;
const unsigned char* checkPw = NULL;
WOLFSSL_EVP_PKEY* key = NULL;
printf(testingFmt, "wolfSSL_EVP_PKEY_new_mac_key()");
@ -9780,15 +9779,15 @@ static void test_wolfSSL_EVP_PKEY_new_mac_key(void)
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, pw, 0));
AssertIntEQ(key->pkey_sz, 0);
AssertNotNull(key->pkey.ptr);
AssertNotNull(checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz));
checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz);
(void)checkPw;
AssertIntEQ((int)checkPwSz, 0);
wolfSSL_EVP_PKEY_free(key);
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, NULL, 0));
AssertIntEQ(key->pkey_sz, 0);
AssertNotNull(key->pkey.ptr);
AssertNotNull(checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz));
checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz);
(void)checkPw;
AssertIntEQ((int)checkPwSz, 0);
wolfSSL_EVP_PKEY_free(key);

View File

@ -569,7 +569,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_mac_key(int type, ENGINE* e,
pkey = wolfSSL_PKEY_new();
if (pkey != NULL) {
pkey->pkey.ptr = (char*)XMALLOC(keylen, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
if (pkey->pkey.ptr == NULL) {
if (pkey->pkey.ptr == NULL && keylen > 0) {
wolfSSL_EVP_PKEY_free(pkey);
pkey = NULL;
}