Skip to content

Commit

Permalink
coverity: don't overwrite obj in wolfSSL_X509_get_ext_d2i.
Browse files Browse the repository at this point in the history
  • Loading branch information
philljj committed Oct 22, 2024
1 parent b535d9f commit 5fd9e99
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,7 @@ void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509, int nid, int* c,
sk = NULL;
}
}

obj = wolfSSL_ASN1_OBJECT_new();
if (obj == NULL) {
WOLFSSL_MSG("Issue creating WOLFSSL_ASN1_OBJECT struct");
Expand All @@ -2455,6 +2456,15 @@ void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509, int nid, int* c,
obj->grp = oidCertExtType;
obj->obj = (byte*)(x509->certPolicies[i]);
obj->objSz = MAX_CERTPOL_SZ;

if (wolfSSL_sk_ASN1_OBJECT_push(sk, obj) <= 0) {
WOLFSSL_MSG("Error pushing ASN1 object onto stack");
wolfSSL_ASN1_OBJECT_free(obj);
wolfSSL_sk_ASN1_OBJECT_pop_free(sk, NULL);
sk = NULL;
}

obj = NULL;
}
else {
WOLFSSL_MSG("No Cert Policy set");
Expand Down

0 comments on commit 5fd9e99

Please sign in to comment.