Browse Source

Convert reference counts in ssl/

Convert reference counts in ssl/ to use |CRYPTO_refcount_t|.

Change-Id: I5d60f641b0c89b1ddfe38bfbd9d7285c60377f4c
Reviewed-on: https://boringssl-review.googlesource.com/4773
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
Adam Langley 9 years ago
committed by Adam Langley
parent
commit
0b5e3908cf
3 changed files with 9 additions and 11 deletions
  1. +3
    -5
      include/openssl/ssl.h
  2. +4
    -4
      ssl/ssl_lib.c
  3. +2
    -2
      ssl/ssl_sess.c

+ 3
- 5
include/openssl/ssl.h View File

@@ -150,15 +150,13 @@
#include <openssl/hmac.h>
#include <openssl/lhash.h>
#include <openssl/pem.h>
#include <openssl/thread.h>
#include <openssl/x509.h>

#if !defined(OPENSSL_WINDOWS)
#include <sys/time.h>
#endif

/* Some code expected to get the threading functions by including ssl.h. */
#include <openssl/thread.h>

/* wpa_supplicant expects to get the version functions from ssl.h */
#include <openssl/crypto.h>

@@ -414,7 +412,7 @@ struct ssl_session_st {
* not ok, we must remember the error for session reuse: */
long verify_result; /* only for servers */

int references;
CRYPTO_refcount_t references;
long timeout;
long time;

@@ -849,7 +847,7 @@ struct ssl_ctx_st {
SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, uint8_t *data, int len,
int *copy);

int references;
CRYPTO_refcount_t references;

/* if defined, these override the X509_verify_cert() calls */
int (*app_verify_callback)(X509_STORE_CTX *, void *);


+ 4
- 4
ssl/ssl_lib.c View File

@@ -293,10 +293,10 @@ SSL *SSL_new(SSL_CTX *ctx) {
s->quiet_shutdown = ctx->quiet_shutdown;
s->max_send_fragment = ctx->max_send_fragment;

CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
CRYPTO_refcount_inc(&ctx->references);
s->ctx = ctx;
s->tlsext_ticket_expected = 0;
CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
CRYPTO_refcount_inc(&ctx->references);
s->initial_ctx = ctx;
if (ctx->tlsext_ecpointformatlist) {
s->tlsext_ecpointformatlist = BUF_memdup(
@@ -1758,7 +1758,7 @@ err2:

void SSL_CTX_free(SSL_CTX *ctx) {
if (ctx == NULL ||
CRYPTO_add(&ctx->references, -1, CRYPTO_LOCK_SSL_CTX) > 0) {
!CRYPTO_refcount_dec_and_test_zero(&ctx->references)) {
return;
}

@@ -2320,7 +2320,7 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) {
ssl_cert_free(ssl->cert);
ssl->cert = ssl_cert_dup(ctx->cert);

CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
CRYPTO_refcount_inc(&ctx->references);
SSL_CTX_free(ssl->ctx); /* decrement reference count */
ssl->ctx = ctx;



+ 2
- 2
ssl/ssl_sess.c View File

@@ -607,14 +607,14 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lock) {

SSL_SESSION *SSL_SESSION_up_ref(SSL_SESSION *session) {
if (session) {
CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION);
CRYPTO_refcount_inc(&session->references);
}
return session;
}

void SSL_SESSION_free(SSL_SESSION *session) {
if (session == NULL ||
CRYPTO_add(&session->references, -1, CRYPTO_LOCK_SSL_SESSION) > 0) {
!CRYPTO_refcount_dec_and_test_zero(&session->references)) {
return;
}



Loading…
Cancel
Save