From 8aeec25c55b031d836ceb2f47dfdaddc1e19b2f2 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 18 Jul 2019 13:55:35 +0000 Subject: [PATCH] Merge of r1426802,1744460,1829799,1824716,1838318,1840678,1861294 *) easy patches to synch 2.4.x and trunk: - core: extend description of r->hostname - mod_proxy_http: Avoid memory allocation before making sure that this handler can handle the URL - core: Save a few cycles in 'ap_parse_form_data()' - mod_cache_socache: Save some cycles - mod_proxy_ftp: Save some cycle - vhost: move an assignment to the end of the loop to ease readability and please a compiler - core: Be a little more verbose when an error in trigerred in 'ap_set_file_slot()' git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1863316 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 19 ------------------- include/httpd.h | 4 +++- modules/cache/mod_cache_socache.c | 4 ++-- modules/proxy/mod_proxy_ftp.c | 20 +++++++++++--------- modules/proxy/mod_proxy_http.c | 5 +++-- server/config.c | 4 ++-- server/util.c | 5 ++--- server/vhost.c | 3 ++- 8 files changed, 25 insertions(+), 39 deletions(-) diff --git a/STATUS b/STATUS index 84b2eecb9a2..54913c9dfbc 100644 --- a/STATUS +++ b/STATUS @@ -127,25 +127,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) easy patches to synch 2.4.x and trunk: - - core: extend description of r->hostname - - mod_proxy_http: Avoid memory allocation before making sure that this handler can handle the URL - - core: Save a few cycles in 'ap_parse_form_data()' - - mod_cache_socache: Save some cycles - - mod_proxy_ftp: Save some cycle - - vhost: move an assignment to the end of the loop to ease readability and please a compiler - - core: Be a little more verbose when an error in trigerred in 'ap_set_file_slot()' - trunk patch: - - http://svn.apache.org/r1426802 - - http://svn.apache.org/r1744460 - - http://svn.apache.org/r1829799 - - http://svn.apache.org/r1824716 - - http://svn.apache.org/r1838318 - - http://svn.apache.org/r1840678 - - http://svn.apache.org/r1861294 - 2.4.x patch: svn merge -c 1426802,1744460,1829799,1824716,1838318,1840678,1861294 ^/httpd/httpd/trunk . - +1: jailletc36, jim, icing - *) cache_storage: be consistent when building a cache key value when CacheKeyBaseURL is used with an URL that contains a :port. PR 53915 [Rein Tollevik ] diff --git a/include/httpd.h b/include/httpd.h index 3391e9e18c6..98a410199bd 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -826,7 +826,9 @@ struct request_rec { int proto_num; /** Protocol string, as given to us, or HTTP/0.9 */ char *protocol; - /** Host, as set by full URI or Host: */ + /** Host, as set by full URI or Host: header. + * For literal IPv6 addresses, this does NOT include the surrounding [ ] + */ const char *hostname; /** Time when the request started */ diff --git a/modules/cache/mod_cache_socache.c b/modules/cache/mod_cache_socache.c index ecaf3763b1d..d5bba99d3eb 100644 --- a/modules/cache/mod_cache_socache.c +++ b/modules/cache/mod_cache_socache.c @@ -217,8 +217,8 @@ static apr_status_t read_table(cache_handle_t *handle, request_rec *r, while (apr_isspace(buffer[colon]) && (colon < *slider)) { colon++; } - apr_table_addn(table, apr_pstrndup(r->pool, (const char *) buffer - + key, len - key), apr_pstrndup(r->pool, + apr_table_addn(table, apr_pstrmemdup(r->pool, (const char *) buffer + + key, len - key), apr_pstrmemdup(r->pool, (const char *) buffer + colon, *slider - colon)); (*slider)++; if (buffer[*slider] == '\n') { diff --git a/modules/proxy/mod_proxy_ftp.c b/modules/proxy/mod_proxy_ftp.c index a29e085abf1..49acdcbc1cd 100644 --- a/modules/proxy/mod_proxy_ftp.c +++ b/modules/proxy/mod_proxy_ftp.c @@ -813,17 +813,19 @@ proxy_ftp_command(const char *cmd, request_rec *r, conn_rec *ftp_ctrl, APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create(c->bucket_alloc)); ap_pass_brigade(ftp_ctrl->output_filters, bb); - /* strip off the CRLF for logging */ - apr_cpystrn(message, cmd, sizeof(message)); - if ((crlf = strchr(message, '\r')) != NULL || - (crlf = strchr(message, '\n')) != NULL) - *crlf = '\0'; - if (strncmp(message,"PASS ", 5) == 0) - strcpy(&message[5], "****"); - ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ">%s", message); + if (APLOGrtrace2(r)) { + /* strip off the CRLF for logging */ + apr_cpystrn(message, cmd, sizeof(message)); + if ((crlf = strchr(message, '\r')) != NULL || + (crlf = strchr(message, '\n')) != NULL) + *crlf = '\0'; + if (strncmp(message,"PASS ", 5) == 0) + strcpy(&message[5], "****"); + ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ">%s", message); + } } - rc = ftp_getrc_msg(ftp_ctrl, bb, message, sizeof message); + rc = ftp_getrc_msg(ftp_ctrl, bb, message, sizeof(message)); if (rc == -1 || rc == 421) strcpy(message,""); if ((crlf = strchr(message, '\r')) != NULL || diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index e86ae1fb2f5..ec1e042c4e0 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1951,12 +1951,12 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker, * and avoid a memory leak */ apr_pool_t *p = r->pool; - apr_uri_t *uri = apr_palloc(p, sizeof(*uri)); + apr_uri_t *uri; /* find the scheme */ u = strchr(url, ':'); if (u == NULL || u[1] != '/' || u[2] != '/' || u[3] == '\0') - return DECLINED; + return DECLINED; if ((u - url) > 14) return HTTP_BAD_REQUEST; scheme = apr_pstrmemdup(p, url, u - url); @@ -2041,6 +2041,7 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker, } /* Step One: Determine Who To Connect To */ + uri = apr_palloc(p, sizeof(*uri)); if ((status = ap_proxy_determine_connection(p, r, conf, worker, backend, uri, &locurl, proxyname, proxyport, req->server_portstr, diff --git a/server/config.c b/server/config.c index 16d4d9fde84..e5ec2b006ea 100644 --- a/server/config.c +++ b/server/config.c @@ -1542,8 +1542,8 @@ AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, void *struct_pt path = ap_server_root_relative(cmd->pool, arg); if (!path) { - return apr_pstrcat(cmd->pool, "Invalid file path ", - arg, NULL); + return apr_pstrcat(cmd->pool, cmd->cmd->name, ": Invalid file path '", + arg, "'", NULL); } *(const char **) ((char*)struct_ptr + offset) = path; diff --git a/server/util.c b/server/util.c index b235a12f5b6..5cdd71d5683 100644 --- a/server/util.c +++ b/server/util.c @@ -2768,12 +2768,11 @@ AP_DECLARE(int) ap_parse_form_data(request_rec *r, ap_filter_t *f, case FORM_NAME: if (offset < HUGE_STRING_LEN) { if ('=' == c) { - buffer[offset] = 0; - offset = 0; pair = (ap_form_pair_t *) apr_array_push(pairs); - pair->name = apr_pstrdup(r->pool, buffer); + pair->name = apr_pstrmemdup(r->pool, buffer, offset); pair->value = apr_brigade_create(r->pool, r->connection->bucket_alloc); state = FORM_VALUE; + offset = 0; } else { buffer[offset++] = c; diff --git a/server/vhost.c b/server/vhost.c index b23b2dd3179..87bdcceeeb5 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -1031,7 +1031,6 @@ static void check_hostalias(request_rec *r) goto found; } } - last_s = s; /* Fallback: does it match the virthost from the sar? */ if (!strcasecmp(host, sar->virthost)) { @@ -1040,6 +1039,8 @@ static void check_hostalias(request_rec *r) virthost_s = s; } } + + last_s = s; } /* If ServerName and ServerAlias check failed, we end up here. If it -- 2.47.3