--- a/src/server/daemon/config.c Mon Apr 06 16:36:25 2015 +0200 +++ b/src/server/daemon/config.c Fri Oct 16 19:23:49 2015 +0200 @@ -38,6 +38,7 @@ #include <sys/mman.h> #include <ucx/string.h> +#include <ucx/utils.h> #include "httplistener.h" #include "config.h" @@ -301,14 +302,9 @@ } // mime file - sstr_t mf = cfg_directivelist_get_str(obj->directives, sstr("MimeFile")); - - sstr_t base = sstr("config/"); - sstr_t file; - file.length = base.length + mf.length; - file.ptr = alloca(file.length + 1); - file.ptr[file.length] = 0; - file = sstrncat(file, 2, base, mf); + sstr_t mf = cfg_directivelist_get_str(obj->directives, sstr("MimeFile")); + sstr_t base = sstr("config/"); + sstr_t file = sstrcat(2, base, mf); ConfigFile *f = cfgmgr_get_file(file); if(f == NULL) { @@ -323,6 +319,8 @@ if(cfgmgr_reload_file(f, cfg, NULL)) { free(f->file.ptr); free(f); + + free(file.ptr); return -1; } cfgmgr_attach_file(f); @@ -330,6 +328,7 @@ cfg->mimetypes = f->data; + free(file.ptr); return 0; } @@ -606,11 +605,8 @@ // load the object config file sstr_t base = sstr("config/"); - sstr_t file; - file.length = base.length + objfile.length + 1; - file.ptr = alloca(file.length); - file.ptr[file.length] = 0; - file = sstrncat(file, 2, base, objfile); + sstr_t file = sstrcat(2, base, objfile); + file = sstrcat(2, base, objfile); // the file is managed by the configuration manager ConfigFile *f = cfgmgr_get_file(file); @@ -624,18 +620,19 @@ if(cfgmgr_reload_file(f, cfg, NULL)) { free(f->file.ptr); free(f); + + free(file.ptr); return -1; } cfgmgr_attach_file(f); } vs->objectfile = sstrdup(file); vs->objects = (HTTPObjectConfig*)f->data; + free(file.ptr); + // load acl config file - file.length = base.length + aclfile.length + 1; - file.ptr = alloca(file.length); - file.ptr[file.length] = 0; - file = sstrncat(file, 2, base, aclfile); + file = sstrcat(2, base, aclfile); ConfigFile *aclf = cfgmgr_get_file(file); if(aclf == NULL) { @@ -648,11 +645,14 @@ if(cfgmgr_reload_file(aclf, cfg, NULL)) { free(aclf->file.ptr); free(aclf); + + free(file.ptr); return -1; } cfgmgr_attach_file(aclf); } vs->acls = aclf->data; + free(file.ptr); // set the access log for the virtual server // TODO: don't use always the default