[mod_dirlisting,mod_redirect,mod_rewrite] abort config parsing if pcre-compile fails or isn't available

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2968 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.36
Stefan Bühler 8 years ago
parent c4f214584a
commit 4a6838103d
  1. 1
      NEWS
  2. 80
      src/mod_dirlisting.c
  3. 1
      src/mod_redirect.c
  4. 1
      src/mod_rewrite.c

@ -9,6 +9,7 @@ NEWS
* add more mime types and a script to generate mime.conf (fixes #2579)
* add support for (Free)BSD extended attributes
* [build] use fortify flags with "extra-warnings"
* [mod_dirlisting,mod_redirect,mod_rewrite] abort config parsing if pcre-compile fails or isn't available
- 1.4.35 - 2014-03-12
* [network/ssl] fix build error if TLSEXT is disabled

@ -198,47 +198,6 @@ FREE_FUNC(mod_dirlisting_free) {
return HANDLER_GO_ON;
}
static int parse_config_entry(server *srv, plugin_config *s, array *ca, const char *option) {
data_unset *du;
if (NULL != (du = array_get_element(ca, option))) {
data_array *da;
size_t j;
if (du->type != TYPE_ARRAY) {
log_error_write(srv, __FILE__, __LINE__, "sss",
"unexpected type for key: ", option, "array of strings");
return HANDLER_ERROR;
}
da = (data_array *)du;
for (j = 0; j < da->value->used; j++) {
if (da->value->data[j]->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "sssbs",
"unexpected type for key: ", option, "[",
da->value->data[j]->key, "](string)");
return HANDLER_ERROR;
}
if (0 != excludes_buffer_append(s->excludes,
((data_string *)(da->value->data[j]))->value)) {
#ifdef HAVE_PCRE_H
log_error_write(srv, __FILE__, __LINE__, "sb",
"pcre-compile failed for", ((data_string *)(da->value->data[j]))->value);
#else
log_error_write(srv, __FILE__, __LINE__, "s",
"pcre support is missing, please install libpcre and the headers");
#endif
}
}
}
return 0;
}
/* handle plugin config and check values */
#define CONFIG_EXCLUDE "dir-listing.exclude"
@ -287,6 +246,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s;
array *ca;
data_unset *du_excludes;
s = calloc(1, sizeof(plugin_config));
s->excludes = excludes_buffer_init();
@ -326,7 +286,43 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
return HANDLER_ERROR;
}
parse_config_entry(srv, s, ca, CONFIG_EXCLUDE);
if (NULL != (du_excludes = array_get_element(ca, CONFIG_EXCLUDE))) {
array *excludes_list;
size_t j;
if (du_excludes->type != TYPE_ARRAY) {
log_error_write(srv, __FILE__, __LINE__, "sss",
"unexpected type for key: ", CONFIG_EXCLUDE, "array of strings");
return HANDLER_ERROR;
}
excludes_list = ((data_array*)du_excludes)->value;
#ifndef HAVE_PCRE_H
if (excludes_list->used > 0) {
log_error_write(srv, __FILE__, __LINE__, "sss",
"pcre support is missing for: ", CONFIG_EXCLUDE, ", please install libpcre and the headers");
return HANDLER_ERROR;
}
#else
for (j = 0; j < excludes_list->used; j++) {
data_unset *du_exclude = excludes_list->data[j];
if (du_exclude->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "sssbs",
"unexpected type for key: ", CONFIG_EXCLUDE, "[",
du_exclude->key, "](string)");
return HANDLER_ERROR;
}
if (0 != excludes_buffer_append(s->excludes, ((data_string*)(du_exclude))->value)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"pcre-compile failed for", ((data_string*)(du_exclude))->value);
return HANDLER_ERROR;
}
}
#endif
}
}
return HANDLER_GO_ON;

@ -129,6 +129,7 @@ SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"pcre-compile failed for", da->value->data[j]->key);
return HANDLER_ERROR;
}
}
}

@ -191,6 +191,7 @@ static int parse_config_entry(server *srv, array *ca, rewrite_rule_buffer *kvb,
once)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"pcre-compile failed for", da->value->data[j]->key);
return HANDLER_ERROR;
}
}
}

Loading…
Cancel
Save