hi all...
currently, all core container directives have an issue (albeit a minor one)
- they require an argument in practice but are allowed to proceed without
one during configuration.
for example
<IfModule >
does not currently throw an error. instead, the config is allowed to
proceed, soaking up the container.
while the subsequent behavior seems ok, to me the lack of feedback for a
malformed directive is less than ideal, especially if users are using a
template to configure apache - something like this
<IfModule [% mymod %]>
or whatever would silently proceed if the substitution variable was
unpopulated, which is a tricky thing to track down
anyway, attached is a patch that makes <IfModule>, <IfDefine>, <Directory>,
<Location>, <Files> (and their regex counterparts), <Limit>, <LimitExcept>,
and <VirtualHost> containers fail if no arguments are specified.
--Geoff
Index: server/core.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.252
diff -u -r1.252 core.c
--- server/core.c 21 Nov 2003 15:02:04 -0000 1.252
+++ server/core.c 8 Dec 2003 15:58:10 -0000
@@ -1552,6 +1552,24 @@
return NULL;
}
+/*
+ * Report a missing-'>' syntax error.
+ */
+static char *unclosed_directive(cmd_parms *cmd)
+{
+ return apr_pstrcat(cmd->pool, cmd->cmd->name,
+ "> directive missing closing '>'", NULL);
+}
+
+/*
+ * Report a missing args in '<Foo >' 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)
@@ -1566,6 +1584,10 @@
return err;
}
+ if (!limited_methods[0]) {
+ return missing_container_arg(cmd);
+ }
+
while (limited_methods[0]) {
char *method = ap_getword_conf(cmd->pool, &limited_methods);
int methnum;
@@ -1610,15 +1632,6 @@
#define USE_ICASE 0
#endif
-/*
- * Report a missing-'>' syntax error.
- */
-static char *unclosed_directive(cmd_parms *cmd)
-{
- return apr_pstrcat(cmd->pool, cmd->cmd->name,
- "> directive missing closing '>'", NULL);
-}
-
static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
{
const char *errmsg;
@@ -1642,6 +1655,10 @@
arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ if (!arg[0]) {
+ return missing_container_arg(cmd);
+ }
+
if (!arg) {
if (thiscmd->cmd_data)
return "<DirectoryMatch > block must specify a path";
@@ -1736,6 +1753,10 @@
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;
@@ -1795,6 +1816,10 @@
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) {
@@ -1860,6 +1885,10 @@
arg++;
}
+ if (!arg[0]) {
+ return missing_container_arg(cmd);
+ }
+
found = ap_find_linked_module(arg);
if ((!not && found) || (not && !found)) {
@@ -1911,6 +1940,10 @@
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;
@@ -1948,6 +1981,10 @@
}
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 <VirtualHost>