From: Paul Querna Date: Mon, 29 Nov 2004 04:15:24 +0000 (+0000) Subject: * server/core.c: Give an error instead of silently going on when a section is missing... X-Git-Tag: 2.1.2~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c448a3d6c5310833c523514862214030160454a7;p=apache * server/core.c: Give an error instead of silently going on when a section is missing an argument. PR: 25460 Submitted By: Geoffrey Young git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@106879 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index a5b5572016..c8f0d56264 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.1.2-dev [Remove entries to the current 2.0 section below, when backported] + *) core: Error out on sections that are missing an argument instead of + silently consuming the section. PR 25460. + [Geoffrey Young, Paul Querna] + *) mod_cache/mod_mem_cache/mod_disk_cache: Move out of experimental. *) Upgraded PCRE to version 5.0. [Brian Pane] diff --git a/server/core.c b/server/core.c index f340585d38..4f82ff8c0a 100644 --- a/server/core.c +++ b/server/core.c @@ -1662,6 +1662,15 @@ static char *unclosed_directive(cmd_parms *cmd) "> directive missing closing '>'", NULL); } +/* + * Report a missing args in '' syntax error. + */ +static char *missing_container_arg(cmd_parms *cmd) +{ + return apr_pstrcat(cmd->pool, cmd->cmd->name, + "> directive requires additional arguments", NULL); +} + AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg) @@ -1683,6 +1692,10 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, limited_methods = apr_pstrndup(cmd->pool, arg, endp - arg); + if (!limited_methods[0]) { + return missing_container_arg(cmd); + } + while (limited_methods[0]) { char *method = ap_getword_conf(cmd->pool, &limited_methods); int methnum; @@ -1750,6 +1763,10 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) arg = apr_pstrndup(cmd->pool, arg, endp - arg); + if (!arg[0]) { + return missing_container_arg(cmd); + } + if (!arg) { if (thiscmd->cmd_data) return " block must specify a path"; @@ -1850,6 +1867,10 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) arg = apr_pstrndup(cmd->pool, arg, endp - arg); + if (!arg[0]) { + return missing_container_arg(cmd); + } + cmd->path = ap_getword_conf(cmd->pool, &arg); cmd->override = OR_ALL|ACCESS_CONF; @@ -1915,6 +1936,10 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) arg = apr_pstrndup(cmd->pool, arg, endp - arg); + if (!arg[0]) { + return missing_container_arg(cmd); + } + cmd->path = ap_getword_conf(cmd->pool, &arg); /* Only if not an .htaccess file */ if (!old_path) { @@ -1986,6 +2011,10 @@ static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg) arg++; } + if (!arg[0]) { + return missing_container_arg(cmd); + } + found = ap_find_linked_module(arg); /* search prelinked stuff */ @@ -2059,6 +2088,10 @@ static const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg) arg++; } + if (!arg[0]) { + return missing_container_arg(cmd); + } + defined = ap_exists_config_define(arg); if ((!not && defined) || (not && !defined)) { ap_directive_t *parent = NULL; @@ -2097,6 +2130,10 @@ static const char *virtualhost_section(cmd_parms *cmd, void *dummy, arg = apr_pstrndup(cmd->pool, arg, endp - arg); + if (!arg[0]) { + return missing_container_arg(cmd); + } + /* FIXME: There's another feature waiting to happen here -- since you can now put multiple addresses/names on a single you might want to use it to group common definitions and then