diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-03-20 22:49:27 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-03-26 13:25:55 +0100 |
commit | 6466cc97e8222ef69c6bd46a2819a0d6947f0084 (patch) | |
tree | d4379f8dcaf8b051c2eff7a4b2f776a911dde116 /crypto/http | |
parent | 1c8505fb7d68fb9c02fac6c11f56bffe6173fc88 (diff) |
HTTP: Fix mem leak of OSSL_HTTP_REQ_CTX_transfer(), rename to ossl_http_req_ctx_transfer()
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14678)
Diffstat (limited to 'crypto/http')
-rw-r--r-- | crypto/http/http_client.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index 744346adbf..4aba5e7761 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -747,7 +747,7 @@ static ASN1_VALUE *BIO_mem_d2i(BIO *mem, const ASN1_ITEM *it) return resp; } -static BIO *OSSL_HTTP_REQ_CTX_transfer(OSSL_HTTP_REQ_CTX *rctx) +static BIO *ossl_http_req_ctx_transfer(OSSL_HTTP_REQ_CTX *rctx) { int sending = 1; int rv; @@ -777,8 +777,6 @@ static BIO *OSSL_HTTP_REQ_CTX_transfer(OSSL_HTTP_REQ_CTX *rctx) } return NULL; } - if (!BIO_up_ref(rctx->mem)) - return NULL; return rctx->mem; } @@ -790,7 +788,7 @@ ASN1_VALUE *OSSL_HTTP_REQ_CTX_sendreq_d2i(OSSL_HTTP_REQ_CTX *rctx, ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER); return NULL; } - return BIO_mem_d2i(OSSL_HTTP_REQ_CTX_transfer(rctx), it); + return BIO_mem_d2i(ossl_http_req_ctx_transfer(rctx), it); } static int update_timeout(int timeout, time_t start_time) @@ -902,7 +900,7 @@ BIO *OSSL_HTTP_transfer(const char *server, const char *port, const char *path, if (rctx == NULL) goto end; - resp = OSSL_HTTP_REQ_CTX_transfer(rctx); + resp = ossl_http_req_ctx_transfer(rctx); if (resp == NULL) { if (rctx->redirection_url != NULL) { if (redirection_url == NULL) @@ -937,14 +935,14 @@ BIO *OSSL_HTTP_transfer(const char *server, const char *port, const char *path, } } } - OSSL_HTTP_REQ_CTX_free(rctx); - /* callback can be used to clean up TLS session */ if (bio_update_fn != NULL - && (*bio_update_fn)(cbio, arg, 0, resp != NULL) == NULL) { - BIO_free(resp); + && (*bio_update_fn)(cbio, arg, 0, resp != NULL) == NULL) resp = NULL; - } + + if (resp != NULL && !BIO_up_ref(resp)) + resp = NULL; + OSSL_HTTP_REQ_CTX_free(rctx); end: /* |