diff options
author | Adam Langley <agl@google.com> | 2016-07-12 20:39:20 +0300 |
---|---|---|
committer | David Benjamin <davidben@google.com> | 2016-07-12 20:55:41 +0300 |
commit | 310d3f63f38cf8a82fa9ae5032e343ba5159eb4d (patch) | |
tree | 18b60b1a10d16a7771c2c7f36bc991d65fa5d307 /crypto | |
parent | 27516f7c9762c2b21ff4add87aa5b7ac41237575 (diff) |
Change |EVP_PKEY_up_ref| to return int.
Upstream have added |EVP_PKEY_up_ref|, but their version returns an int.
Having this function with a different signature like that is dangerous
so this change aligns BoringSSL with upstream. Users of this function in
Chromium and internally should already have been updated.
Change-Id: I0a7aeaf1a1ca3b0f0c635e2ee3826aa100b18157
Reviewed-on: https://boringssl-review.googlesource.com/8736
Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/evp.c | 4 | ||||
-rw-r--r-- | crypto/evp/evp_ctx.c | 9 | ||||
-rw-r--r-- | crypto/x509/x_pubkey.c | 6 |
3 files changed, 12 insertions, 7 deletions
diff --git a/crypto/evp/evp.c b/crypto/evp/evp.c index ee207f9b..3b4b05bb 100644 --- a/crypto/evp/evp.c +++ b/crypto/evp/evp.c @@ -108,9 +108,9 @@ void EVP_PKEY_free(EVP_PKEY *pkey) { OPENSSL_free(pkey); } -EVP_PKEY *EVP_PKEY_up_ref(EVP_PKEY *pkey) { +int EVP_PKEY_up_ref(EVP_PKEY *pkey) { CRYPTO_refcount_inc(&pkey->references); - return pkey; + return 1; } int EVP_PKEY_is_opaque(const EVP_PKEY *pkey) { diff --git a/crypto/evp/evp_ctx.c b/crypto/evp/evp_ctx.c index f510f6c7..f7d4b41b 100644 --- a/crypto/evp/evp_ctx.c +++ b/crypto/evp/evp_ctx.c @@ -112,7 +112,8 @@ static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) { ret->operation = EVP_PKEY_OP_UNDEFINED; if (pkey) { - ret->pkey = EVP_PKEY_up_ref(pkey); + EVP_PKEY_up_ref(pkey); + ret->pkey = pkey; } if (pmeth->init) { @@ -165,14 +166,16 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) { rctx->operation = pctx->operation; if (pctx->pkey) { - rctx->pkey = EVP_PKEY_up_ref(pctx->pkey); + EVP_PKEY_up_ref(pctx->pkey); + rctx->pkey = pctx->pkey; if (rctx->pkey == NULL) { goto err; } } if (pctx->peerkey) { - rctx->peerkey = EVP_PKEY_up_ref(pctx->peerkey); + EVP_PKEY_up_ref(pctx->peerkey); + rctx->peerkey = pctx->peerkey; if (rctx->peerkey == NULL) { goto err; } diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index 23534b2b..3d07d661 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -141,7 +141,8 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) CRYPTO_STATIC_MUTEX_lock_read(&g_pubkey_lock); if (key->pkey != NULL) { CRYPTO_STATIC_MUTEX_unlock_read(&g_pubkey_lock); - return EVP_PKEY_up_ref(key->pkey); + EVP_PKEY_up_ref(key->pkey); + return key->pkey; } CRYPTO_STATIC_MUTEX_unlock_read(&g_pubkey_lock); @@ -170,7 +171,8 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) } OPENSSL_free(spki); - return EVP_PKEY_up_ref(ret); + EVP_PKEY_up_ref(ret); + return ret; error: OPENSSL_free(spki); |