diff options
author | David Benjamin <davidben@chromium.org> | 2014-08-06 06:22:49 +0400 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-08-07 04:06:34 +0400 |
commit | 150c617cfce408faf1274a60e5db194595cb4473 (patch) | |
tree | 35dc71d4a4f1afe75561befbb1543470f96ed514 /ssl/ssl_cert.c | |
parent | e6e15fc3a19ac6e4317d7245df24313c261fc2bb (diff) |
Add X509_up_ref and use it internally.
Avoid needing to manually increment the reference count and using the right
lock, both here and in Chromium.
Change-Id: If116ebc224cfb1c4711f7e2c06f1fd2c97af21dd
Reviewed-on: https://boringssl-review.googlesource.com/1415
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'ssl/ssl_cert.c')
-rw-r--r-- | ssl/ssl_cert.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index c3994c40..7d398d90 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -261,8 +261,7 @@ CERT *ssl_cert_dup(CERT *cert) CERT_PKEY *rpk = ret->pkeys + i; if (cpk->x509 != NULL) { - rpk->x509 = cpk->x509; - CRYPTO_add(&rpk->x509->references, 1, CRYPTO_LOCK_X509); + rpk->x509 = X509_up_ref(cpk->x509); } if (cpk->privatekey != NULL) @@ -365,14 +364,12 @@ CERT *ssl_cert_dup(CERT *cert) if (cert->verify_store) { - CRYPTO_add(&cert->verify_store->references, 1, CRYPTO_LOCK_X509_STORE); - ret->verify_store = cert->verify_store; + ret->verify_store = X509_up_ref(cert->verify_store); } if (cert->chain_store) { - CRYPTO_add(&cert->chain_store->references, 1, CRYPTO_LOCK_X509_STORE); - ret->chain_store = cert->chain_store; + ret->chain_store = X509_up_ref(cert->chain_store); } ret->ciphers_raw = NULL; @@ -529,7 +526,7 @@ int ssl_cert_add1_chain_cert(CERT *c, X509 *x) { if (!ssl_cert_add0_chain_cert(c, x)) return 0; - CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); + X509_up_ref(x); return 1; } @@ -1214,7 +1211,7 @@ int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain, int ref) X509_STORE_free(*pstore); *pstore = store; if (ref && store) - CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE); + X509_up_ref(store); return 1; } |