diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2023-08-08 22:47:50 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-08-10 17:30:16 +0200 |
commit | 36ff77b28469a9827005a7c42938662b1dfe731c (patch) | |
tree | 89f774f6b5e4de986c2e1d376852fed76711ef1e /crypto/http/http_client.c | |
parent | 0c1cdb7cefa8edbcc29b9d799ac28c6fbc7e0a30 (diff) |
OSSL_HTTP_{REQ_CTX_set_request_line(),_set1_request()}: backward compat w.r.t. path parameter
Fixes #17923
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21690)
(cherry picked from commit 45c02183c65f0e1abf59909c2900764606334664)
Diffstat (limited to 'crypto/http/http_client.c')
-rw-r--r-- | crypto/http/http_client.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index ee41c03103..e3ccc6c4cc 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -164,7 +164,8 @@ void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx, /* * Create request line using |rctx| and |path| (or "/" in case |path| is NULL). - * Server name (and port) must be given if and only if plain HTTP proxy is used. + * Server name (and optional port) must be given if and only if + * a plain HTTP proxy is used and |path| does not begin with 'http://'. */ int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST, const char *server, const char *port, @@ -193,11 +194,17 @@ int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST, return 0; } - /* Make sure path includes a forward slash */ - if (path == NULL) + /* Make sure path includes a forward slash (abs_path) */ + if (path == NULL) { path = "/"; - if (path[0] != '/' && BIO_printf(rctx->mem, "/") <= 0) + } else if (HAS_PREFIX(path, "http://")) { /* absoluteURI for proxy use */ + if (server != NULL) { + ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_INVALID_ARGUMENT); + return 0; + } + } else if (path[0] != '/' && BIO_printf(rctx->mem, "/") <= 0) { return 0; + } /* * Add (the rest of) the path and the HTTP version, * which is fixed to 1.0 for straightforward implementation of keep-alive |