diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-05-01 19:47:38 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-05-14 19:24:42 +0200 |
commit | 8801240bc5d5e7fe29b2635bbf9c4d45fd1b2996 (patch) | |
tree | 28163aeaebaf14d59f1b7e9f2854ea21aec10c20 /crypto/http/http_client.c | |
parent | 19f97fe6f10bf0d1daec26a9ae2ad919127c67d5 (diff) |
OSSL_HTTP_get(): Do not close connection if redirect to same server
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15053)
Diffstat (limited to 'crypto/http/http_client.c')
-rw-r--r-- | crypto/http/http_client.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index f46cc2714f..50f1e6d378 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -1056,25 +1056,20 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy, &port, NULL /* port_num */, &path, NULL, NULL)) break; - new_rpath: rctx = OSSL_HTTP_open(host, port, proxy, no_proxy, use_ssl, bio, rbio, bio_update_fn, arg, buf_size, max_resp_len, timeout); + new_rpath: if (rctx != NULL) { if (!OSSL_HTTP_set_request(rctx, path, headers, NULL /* content_type */, NULL /* req_mem */, expected_ct, expect_asn1, -1 /* use same max time */, - 0 /* no keep_alive */)) { + 0 /* no keep_alive */)) OSSL_HTTP_REQ_CTX_free(rctx); - } else { + else resp = OSSL_HTTP_exchange(rctx, &redirection_url); - if (!OSSL_HTTP_close(rctx, resp != NULL)) { - BIO_free(resp); - resp = NULL; - } - } } OPENSSL_free(path); if (resp == NULL && redirection_url != NULL) { @@ -1088,12 +1083,18 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy, } OPENSSL_free(host); OPENSSL_free(port); + (void)OSSL_HTTP_close(rctx, 1); continue; } + /* if redirection not allowed, ignore it */ OPENSSL_free(redirection_url); } OPENSSL_free(host); OPENSSL_free(port); + if (!OSSL_HTTP_close(rctx, resp != NULL)) { + BIO_free(resp); + resp = NULL; + } break; } OPENSSL_free(current_url); |