From 647a5dbf10227d65919b49d078da4eaca313f921 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Tue, 11 May 2021 15:45:22 +0200 Subject: [PATCH] Add OSSL_ prefix to HTTP_DEFAULT_MAX_{LINE_LENGTH,RESP_LEN} Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15053) --- apps/lib/apps.c | 4 ++-- crypto/http/http_client.c | 6 +++--- crypto/x509/x_all.c | 2 +- doc/man3/OSSL_HTTP_REQ_CTX.pod | 6 +++--- doc/man3/OSSL_HTTP_transfer.pod | 5 ++--- include/openssl/http.h | 4 ++-- test/http_test.c | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/lib/apps.c b/apps/lib/apps.c index d32f6c5490..fa63410359 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -2504,7 +2504,7 @@ ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy, mem = OSSL_HTTP_get(url, proxy, no_proxy, NULL /* bio */, NULL /* rbio */, app_http_tls_cb, &info, 0 /* buf_size */, headers, expected_content_type, 1 /* expect_asn1 */, - HTTP_DEFAULT_MAX_RESP_LEN, timeout); + OSSL_HTTP_DEFAULT_MAX_RESP_LEN, timeout); resp = ASN1_item_d2i_bio(it, mem, NULL); BIO_free(mem); @@ -2540,7 +2540,7 @@ ASN1_VALUE *app_http_post_asn1(const char *host, const char *port, app_http_tls_cb, &info, 0 /* buf_size */, headers, content_type, req_mem, expected_content_type, 1 /* expect_asn1 */, - HTTP_DEFAULT_MAX_RESP_LEN, timeout, + OSSL_HTTP_DEFAULT_MAX_RESP_LEN, timeout, 0 /* keep_alive */); BIO_free(req_mem); res = ASN1_item_d2i_bio(rsp_it, rsp, NULL); diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index b1da0d8023..cd6a51989f 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -101,7 +101,7 @@ OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size) if ((rctx = OPENSSL_zalloc(sizeof(*rctx))) == NULL) return NULL; rctx->state = OHS_ERROR; - rctx->buf_size = buf_size > 0 ? buf_size : HTTP_DEFAULT_MAX_LINE_LENGTH; + rctx->buf_size = buf_size > 0 ? buf_size : OSSL_HTTP_DEFAULT_MAX_LINE_LEN; rctx->buf = OPENSSL_malloc(rctx->buf_size); rctx->wbio = wbio; rctx->rbio = rbio; @@ -109,7 +109,7 @@ OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size) OPENSSL_free(rctx); return NULL; } - rctx->max_resp_len = HTTP_DEFAULT_MAX_RESP_LEN; + rctx->max_resp_len = OSSL_HTTP_DEFAULT_MAX_RESP_LEN; /* everything else is 0, e.g. rctx->len_to_send, or NULL, e.g. rctx->mem */ return rctx; } @@ -160,7 +160,7 @@ void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx, ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER); return; } - rctx->max_resp_len = len != 0 ? (size_t)len : HTTP_DEFAULT_MAX_RESP_LEN; + rctx->max_resp_len = len != 0 ? (size_t)len : OSSL_HTTP_DEFAULT_MAX_RESP_LEN; } /* diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index 1bd47ce654..ba400d1103 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -79,7 +79,7 @@ static ASN1_VALUE *simple_get_asn1(const char *url, BIO *bio, BIO *rbio, bio, rbio, NULL /* cb */ , NULL /* arg */, 1024 /* buf_size */, NULL /* headers */, NULL /* expected_ct */, 1 /* expect_asn1 */, - HTTP_DEFAULT_MAX_RESP_LEN, timeout); + OSSL_HTTP_DEFAULT_MAX_RESP_LEN, timeout); ASN1_VALUE *res = ASN1_item_d2i_bio(it, mem, NULL); BIO_free(mem); diff --git a/doc/man3/OSSL_HTTP_REQ_CTX.pod b/doc/man3/OSSL_HTTP_REQ_CTX.pod index 99396dfe7e..ec358d265f 100644 --- a/doc/man3/OSSL_HTTP_REQ_CTX.pod +++ b/doc/man3/OSSL_HTTP_REQ_CTX.pod @@ -64,8 +64,8 @@ which gets populated with the B to write/send the request to (I), the B to read/receive the response from (I, which may be equal to I), and the maximum expected response header line length I. A value <= 0 indicates that -the B of 4KiB should be used. -This length is also used as the number of content bytes that are read at a time. +the B of 4KiB should be used. +I is also used as the number of content bytes that are read at a time. The allocated context structure is also populated with an internal allocated memory B, which collects the HTTP request and additional headers as text. @@ -154,7 +154,7 @@ in I if provided by the server as header field, else 0. OSSL_HTTP_REQ_CTX_set_max_response_length() sets the maximum allowed response content length for I to I. If not set or I is 0 -then the B is used, which currently is 100 KiB. +then the B is used, which currently is 100 KiB. If the C header is present and exceeds this value or the content is an ASN.1 encoded structure with a length exceeding this value or both length indications are present but disagree then an error occurs. diff --git a/doc/man3/OSSL_HTTP_transfer.pod b/doc/man3/OSSL_HTTP_transfer.pod index 0133122558..d6eb39f652 100644 --- a/doc/man3/OSSL_HTTP_transfer.pod +++ b/doc/man3/OSSL_HTTP_transfer.pod @@ -123,9 +123,8 @@ Here is a simple example that supports TLS connections (but not via a proxy): After disconnect the modified BIO will be deallocated using BIO_free_all(). The I parameter specifies the response header maximum line length. -A value <= 0 indicates that -the B of 4KiB should be used. -This length is also used as the number of content bytes that are read at a time. +A value <= 0 means that the B (4KiB) is used. +I is also used as the number of content bytes that are read at a time. If the I parameter is > 0 this indicates the maximum number of seconds the overall HTTP transfer (i.e., connection setup if needed, diff --git a/include/openssl/http.h b/include/openssl/http.h index 2140d5d2f8..76d20c5242 100644 --- a/include/openssl/http.h +++ b/include/openssl/http.h @@ -33,8 +33,8 @@ extern "C" { # define OPENSSL_HTTP_PROXY "HTTP_PROXY" # define OPENSSL_HTTPS_PROXY "HTTPS_PROXY" -#define HTTP_DEFAULT_MAX_LINE_LENGTH (4 * 1024) -#define HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024) +#define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024) +#define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024) /* Low-level HTTP API */ OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size); diff --git a/test/http_test.c b/test/http_test.c index 907650453d..b9f7452744 100644 --- a/test/http_test.c +++ b/test/http_test.c @@ -133,13 +133,13 @@ static int test_http_x509(int do_get) wbio, rbio, NULL /* bio_update_fn */, NULL /* arg */, 0 /* buf_size */, headers, content_type, 1 /* expect_asn1 */, - HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */) + OSSL_HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */) : OSSL_HTTP_transfer(NULL, NULL /* host */, NULL /* port */, RPATH, 0 /* use_ssl */,NULL /* proxy */, NULL /* no_pr */, wbio, rbio, NULL /* bio_fn */, NULL /* arg */, 0 /* buf_size */, headers, content_type, req, content_type, 1 /* expect_asn1 */, - HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */, + OSSL_HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */, 0 /* keep_alive */); rcert = d2i_X509_bio(rsp, NULL); BIO_free(rsp); -- 2.34.1