Add X509_CRL_up_ref function

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Dr. Stephen Henson 2015-08-31 20:30:20 +01:00
parent a7e974c7be
commit 65cbf983ca
7 changed files with 17 additions and 11 deletions

View File

@ -517,7 +517,7 @@ int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl)
int r;
r = CMS_add0_crl(cms, crl);
if (r > 0)
CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(crl);
return r;
}
@ -570,7 +570,7 @@ STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms)
sk_X509_CRL_pop_free(crls, X509_CRL_free);
return NULL;
}
CRYPTO_add(&rch->d.crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(rch->d.crl);
}
}
return crls;

View File

@ -341,7 +341,7 @@ int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
return 0;
}
CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(crl);
if (!sk_X509_CRL_push(*sk, crl)) {
X509_CRL_free(crl);
return 0;

View File

@ -821,7 +821,7 @@ X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[],
STOREerr(STORE_F_STORE_GENERATE_CRL, STORE_R_FAILED_GENERATING_CRL);
return 0;
}
CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(object->data.crl);
#ifdef REF_PRINT
REF_PRINT("X509_CRL", data);
#endif
@ -845,7 +845,7 @@ X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[],
STOREerr(STORE_F_STORE_GET_CRL, STORE_R_FAILED_GETTING_KEY);
return 0;
}
CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(object->data.crl);
#ifdef REF_PRINT
REF_PRINT("X509_CRL", data);
#endif
@ -869,7 +869,7 @@ int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[],
return 0;
}
CRYPTO_add(&data->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(data);
#ifdef REF_PRINT
REF_PRINT("X509_CRL", data);
#endif
@ -950,7 +950,7 @@ X509_CRL *STORE_list_crl_next(STORE *s, void *handle)
STOREerr(STORE_F_STORE_LIST_CRL_NEXT, STORE_R_FAILED_LISTING_KEYS);
return 0;
}
CRYPTO_add(&object->data.crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(object->data.crl);
#ifdef REF_PRINT
REF_PRINT("X509_CRL", data);
#endif

View File

@ -409,7 +409,7 @@ void X509_OBJECT_up_ref_count(X509_OBJECT *a)
CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509);
break;
case X509_LU_CRL:
CRYPTO_add(&a->data.crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(a->data.crl);
break;
}
}
@ -565,7 +565,7 @@ STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm)
for (i = 0; i < cnt; i++, idx++) {
obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
x = obj->data.crl;
CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(x);
if (!sk_X509_CRL_push(sk, x)) {
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
X509_CRL_free(x);

View File

@ -1025,7 +1025,7 @@ static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
*pissuer = best_crl_issuer;
*pscore = best_score;
*preasons = best_reasons;
CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(best_crl);
X509_CRL_free(*pdcrl);
*pdcrl = NULL;
get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
@ -1123,7 +1123,7 @@ static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
if (check_delta_base(delta, base)) {
if (check_crl_time(ctx, delta, 0))
*pscore |= CRL_SCORE_TIME_DELTA;
CRYPTO_add(&delta->references, 1, CRYPTO_LOCK_X509_CRL);
X509_CRL_up_ref(delta);
*dcrl = delta;
return;
}

View File

@ -132,6 +132,11 @@ int X509_CRL_sort(X509_CRL *c)
return 1;
}
void X509_CRL_up_ref(X509_CRL *crl)
{
CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL);
}
int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm)
{
ASN1_TIME *in;

View File

@ -837,6 +837,7 @@ int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
int X509_CRL_sort(X509_CRL *crl);
void X509_CRL_up_ref(X509_CRL *crl);
int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);