From: Graham Leggett Date: Fri, 14 Apr 2023 14:02:11 +0000 (+0000) Subject: core: Be explicit if an enclosing directive contains a path or a X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1925882d55cceb6de7392ea8285d2cd74d6924bc;p=thirdparty%2Fapache%2Fhttpd.git core: Be explicit if an enclosing directive contains a path or a regex. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909135 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 79775ef3f1e..22f958ab9f6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + *) core: Be explicit if an enclosing directive contains a path or a + regex. [Graham Leggett] + *) mod_http2: fixed a crash during connection termination. See PR 66539. [Stefan Eissing] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index c0e31163162..613ebfe10fe 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -714,6 +714,7 @@ * 20211221.9 (2.5.1-dev) Add additional hcmethod_t enums and PROXY_WORKER_IS_ERROR * 20211221.10 (2.5.1-dev) Add ap_proxy_canonenc_ex * 20211221.11 (2.5.1-dev) Add AP_CTIME_OPTION_GMTOFF to util_time.h + * 20211221.12 (2.5.1-dev) Add cmd_parms->regex */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -721,7 +722,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20211221 #endif -#define MODULE_MAGIC_NUMBER_MINOR 11 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 12 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/server/core.c b/server/core.c index 1e16f03a9e6..4c4715c684d 100644 --- a/server/core.c +++ b/server/core.c @@ -2515,7 +2515,6 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) char *old_path = cmd->path; core_dir_config *conf; ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool); - ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT); @@ -2538,16 +2537,17 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - if (!cmd->path) + if (!cmd->path) { return " block must specify a path"; - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); - if (!r) { + } + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + if (!cmd->regex) { return "Regex could not be compiled"; } } else if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); - if (!r) { + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + if (!cmd->regex) { return "Regex could not be compiled"; } } @@ -2587,13 +2587,13 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) if (errmsg != NULL) return errmsg; - conf->r = r; + conf->r = cmd->regex; conf->d = cmd->path; conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0); - if (r) { + if (cmd->regex) { conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *)); - ap_regname(r, conf->refs, AP_REG_MATCH, 1); + ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1); } /* Make this explicit - the "/" root has 0 elements, that is, we @@ -2625,7 +2625,6 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; - ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool); const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT); @@ -2647,15 +2646,15 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) cmd->override = OR_ALL|ACCESS_CONF; if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); - if (!r) { + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); + if (!cmd->regex) { return "Regex could not be compiled"; } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); - if (!r) { + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); + if (!cmd->regex) { return "Regex could not be compiled"; } } @@ -2670,11 +2669,11 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) conf->d = apr_pstrdup(cmd->pool, cmd->path); /* No mangling, please */ conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0; - conf->r = r; + conf->r = cmd->regex; - if (r) { + if (cmd->regex) { conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *)); - ap_regname(r, conf->refs, AP_REG_MATCH, 1); + ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1); } ap_add_per_url_conf(cmd->server, new_url_conf); @@ -2697,7 +2696,6 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; - ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool); const char *err = ap_check_cmd_context(cmd, @@ -2724,15 +2722,15 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) } if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); - if (!r) { + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + if (!cmd->regex) { return "Regex could not be compiled"; } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); - if (!r) { + cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + if (!cmd->regex) { return "Regex could not be compiled"; } } @@ -2757,11 +2755,11 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) conf->d = cmd->path; conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0; - conf->r = r; + conf->r = cmd->regex; - if (r) { + if (cmd->regex) { conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *)); - ap_regname(r, conf->refs, AP_REG_MATCH, 1); + ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1); } ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);