summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-05-01 22:04:17 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-05-14 19:24:42 +0200
commit22fe2b129922bc9322c41ce8beff1551c078c838 (patch)
tree8cb6fe44cb8baf2ec35bdd05dabd9747559ed155
parent8801240bc5d5e7fe29b2635bbf9c4d45fd1b2996 (diff)
OSSL_HTTP_transfer(): Fix error reporting in case rctx->server is NULL
Also improve doc of OSSL_parse_url() and OSSL_HTTP_parse_url(). Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15053)
-rw-r--r--crypto/http/http_client.c13
-rw-r--r--doc/man3/OSSL_HTTP_parse_url.pod8
2 files changed, 11 insertions, 10 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c
index 50f1e6d378..ee97f64ef6 100644
--- a/crypto/http/http_client.c
+++ b/crypto/http/http_client.c
@@ -985,17 +985,16 @@ BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url)
#endif
) {
if (rctx->server != NULL) {
- BIO_snprintf(buf, 200, "server=http%s://%s",
- rctx->use_ssl ? "s" : "", rctx->server);
- if (rctx->port != NULL)
- BIO_snprintf(buf + strlen(buf), 200 - strlen(buf),
- ":%s", rctx->port);
+ BIO_snprintf(buf, sizeof(buf), "server=http%s://%s%s%s",
+ rctx->use_ssl ? "s" : "", rctx->server,
+ rctx->port != NULL ? ":" : "",
+ rctx->port != NULL ? rctx->port : "");
+ ERR_add_error_data(1, buf);
}
- ERR_add_error_data(1, buf);
if (rctx->proxy != NULL)
ERR_add_error_data(2, " proxy=", rctx->proxy);
if (err == 0) {
- BIO_snprintf(buf, 200, " peer has disconnected%s",
+ BIO_snprintf(buf, sizeof(buf), " peer has disconnected%s",
rctx->use_ssl ? " violating the protocol" :
", likely because it requires the use of TLS");
ERR_add_error_data(1, buf);
diff --git a/doc/man3/OSSL_HTTP_parse_url.pod b/doc/man3/OSSL_HTTP_parse_url.pod
index 60589b6bf9..559ff1dd08 100644
--- a/doc/man3/OSSL_HTTP_parse_url.pod
+++ b/doc/man3/OSSL_HTTP_parse_url.pod
@@ -31,7 +31,7 @@ L<openssl_user_macros(7)>:
OSSL_parse_url() parses its input string I<url> as a URL of the form
C<[scheme://][userinfo@]host[:port][/path][?query][#fragment]> and splits it up
into scheme, userinfo, host, port, path, query, and fragment components.
-The host component may be a DNS name or an IP address
+The host (or server) component may be a DNS name or an IP address
where IPv6 addresses should be enclosed in square brackets C<[> and C<]>.
The port component is optional and defaults to C<0>.
If given, it must be in decimal form. If the I<pport_num> argument is not NULL
@@ -52,6 +52,8 @@ If I<pssl> is not NULL, I<*pssl> is assigned 1 in case parsing was successful
and the scheme is C<https>, else 0.
The port component is optional and defaults to C<443> if the scheme is C<https>,
else C<80>.
+Note that relative paths must be given with a leading C</>,
+otherwise the first path element is interpreted as the hostname.
Calling the deprecated function OCSP_parse_url(url, host, port, path, ssl)
is equivalent to
@@ -59,7 +61,7 @@ OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL).
=head1 RETURN VALUES
-OSSL_HTTP_parse_url() and OCSP_parse_url()
+OSSL_parse_url(), OSSL_HTTP_parse_url(), and OCSP_parse_url()
return 1 on success, 0 on error.
=head1 SEE ALSO
@@ -68,7 +70,7 @@ L<OSSL_HTTP_transfer(3)>
=head1 HISTORY
-OOSSL_HTTP_parse_url() was added in OpenSSL 3.0.
+OSSL_parse_url() and OSSL_HTTP_parse_url() were added in OpenSSL 3.0.
OCSP_parse_url() was deprecated in OpenSSL 3.0.
=head1 COPYRIGHT