[core] fix crash if invalid config file (fixes #2798)

If lighttpd.conf is invalid, some modules may not have initialized their
per-context config structures, but will have their free-functions
called, which should not be run on uninitialized per-context configs.

x-ref:
  "Segfault with simple-vhost.debug = "enable""
  https://redmine.lighttpd.net/issues/2798
personal/stbuehler/mod-csrf
Glenn Strauss 6 years ago
parent 46ff978fa0
commit 1485cb401b
  1. 4
      src/mod_openssl.c
  2. 1
      src/mod_simple_vhost.c
  3. 1
      src/mod_status.c

@ -113,7 +113,9 @@ FREE_FUNC(mod_openssl_free)
if (p->config_storage) {
for (size_t i = 0; i < srv->config_context->used; ++i) {
plugin_config *s = p->config_storage[i];
int copy = s->ssl_enabled && buffer_string_is_empty(s->ssl_pemfile);
int copy;
if (NULL == s) continue;
copy = s->ssl_enabled && buffer_string_is_empty(s->ssl_pemfile);
buffer_free(s->ssl_pemfile);
buffer_free(s->ssl_ca_file);
buffer_free(s->ssl_cipher_list);

@ -55,6 +55,7 @@ FREE_FUNC(mod_simple_vhost_free) {
size_t i;
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s = p->config_storage[i];
if (NULL == s) continue;
buffer_free(s->document_root);
buffer_free(s->default_host);

@ -85,6 +85,7 @@ FREE_FUNC(mod_status_free) {
size_t i;
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s = p->config_storage[i];
if (NULL == s) continue;
buffer_free(s->status_url);
buffer_free(s->statistics_url);

Loading…
Cancel
Save