Skip to content

Commit

Permalink
Merge pull request #6500 from SparkiDev/tests_api_expect_4
Browse files Browse the repository at this point in the history
Test api.c: change more tests to use Expect instead of Assert
  • Loading branch information
dgarske authored Jun 22, 2023
2 parents fb35526 + e467112 commit 6697181
Show file tree
Hide file tree
Showing 10 changed files with 4,886 additions and 5,477 deletions.
4 changes: 3 additions & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ WOLFSSL_TXT_DB *wolfSSL_TXT_DB_read(WOLFSSL_BIO *in, int num)
failed = 0;
error:
if (failed && ret) {
XFREE(ret, NULL, DYNAMIC_TYPE_OPENSSL);
wolfSSL_TXT_DB_free(ret);
ret = NULL;
}
if (buf) {
Expand Down Expand Up @@ -458,6 +458,7 @@ int wolfSSL_CONF_add_string(WOLFSSL_CONF *conf,
}
if (wolfSSL_sk_CONF_VALUE_push(conf->data, value) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("wolfSSL_sk_CONF_VALUE_push error");
wolfssl_sk_pop_type(sk, STACK_TYPE_CONF_VALUE);
return WOLFSSL_FAILURE;
}

Expand Down Expand Up @@ -948,6 +949,7 @@ int wolfSSL_NCONF_load(WOLFSSL_CONF *conf, const char *file, long *eline)

if (wolfSSL_CONF_add_string(conf, section, newVal) !=
WOLFSSL_SUCCESS) {
wolfSSL_X509V3_conf_free(newVal);
WOLFSSL_MSG("wolfSSL_CONF_add_string error");
goto cleanup;
}
Expand Down
8 changes: 5 additions & 3 deletions src/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
InitDecodedCert(cert, subject->derCert->buffer,
subject->derCert->length, NULL);
if (ParseCertRelative(cert, CERT_TYPE, VERIFY_OCSP, cm) != 0) {
FreeDecodedCert(cert);
goto out;
}
else {
Expand All @@ -676,11 +677,12 @@ WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
if (ret != 0) {
if (derCert != NULL)
FreeDer(&derCert);
if (certId != NULL)
if (certId != NULL) {
XFREE(certId, cm->heap, DYNAMIC_TYPE_OPENSSL);
certId = NULL;
}
if (certStatus)
XFREE(certStatus, cm->heap, DYNAMIC_TYPE_OPENSSL);
return NULL;
}

#ifdef WOLFSSL_SMALL_STACK
Expand Down Expand Up @@ -1115,7 +1117,7 @@ WOLFSSL_OCSP_CERTID* wolfSSL_d2i_OCSP_CERTID(WOLFSSL_OCSP_CERTID** cidOut,
}
}

if (cid && (!cidOut || cid != *cidOut)) {
if ((cid != NULL) && ((cidOut == NULL) || (cid != *cidOut))) {
XFREE(cid, NULL, DYNAMIC_TYPE_OPENSSL);
}

Expand Down
25 changes: 25 additions & 0 deletions src/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ WOLFSSL_RSA_METHOD *wolfSSL_RSA_meth_new(const char *name, int flags)
if (err) {
/* meth->name won't be allocated on error. */
XFREE(meth, NULL, DYNAMIC_TYPE_OPENSSL);
meth = NULL;
}
return meth;
}
Expand Down Expand Up @@ -2751,6 +2752,15 @@ int wolfSSL_RSA_set0_crt_params(WOLFSSL_RSA *rsa, WOLFSSL_BIGNUM *dmp1,

/* Set the values into the wolfCrypt RSA key. */
if (SetRsaInternal(rsa) != 1) {
if (dmp1 != NULL) {
rsa->dmp1 = NULL;
}
if (dmq1 != NULL) {
rsa->dmq1 = NULL;
}
if (iqmp != NULL) {
rsa->iqmp = NULL;
}
ret = 0;
}
}
Expand Down Expand Up @@ -2815,6 +2825,12 @@ int wolfSSL_RSA_set0_factors(WOLFSSL_RSA *rsa, WOLFSSL_BIGNUM *p,

/* Set the values into the wolfCrypt RSA key. */
if (SetRsaInternal(rsa) != 1) {
if (p != NULL) {
rsa->p = NULL;
}
if (q != NULL) {
rsa->q = NULL;
}
ret = 0;
}
}
Expand Down Expand Up @@ -2890,6 +2906,15 @@ int wolfSSL_RSA_set0_key(WOLFSSL_RSA *rsa, WOLFSSL_BIGNUM *n, WOLFSSL_BIGNUM *e,

/* Set the values into the wolfCrypt RSA key. */
if (SetRsaInternal(rsa) != 1) {
if (n != NULL) {
rsa->n = NULL;
}
if (e != NULL) {
rsa->e = NULL;
}
if (d != NULL) {
rsa->d = NULL;
}
ret = 0;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -13490,7 +13490,7 @@ int wolfSSL_X509_set_notBefore(WOLFSSL_X509* x509, const WOLFSSL_ASN1_TIME* t)
int wolfSSL_X509_set_serialNumber(WOLFSSL_X509* x509, WOLFSSL_ASN1_INTEGER* s)
{
WOLFSSL_ENTER("wolfSSL_X509_set_serialNumber");
if (!x509 || !s || s->length >= EXTERNAL_SERIAL_SIZE)
if (x509 == NULL || s == NULL || s->length >= EXTERNAL_SERIAL_SIZE)
return WOLFSSL_FAILURE;

/* WOLFSSL_ASN1_INTEGER has type | size | data
Expand Down Expand Up @@ -13970,6 +13970,9 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req,
}
}
ret = wolfSSL_sk_push(req->reqAttributes, attr);
if (ret != WOLFSSL_SUCCESS) {
wolfSSL_X509_ATTRIBUTE_free(attr);
}
}

return ret;
Expand Down
Loading

0 comments on commit 6697181

Please sign in to comment.