aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/config.c b/config.c
index 28fbecb..7cd94c6 100644
--- a/config.c
+++ b/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.32 2015/01/21 22:21:05 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.33 2015/02/05 10:46:17 reyk Exp $ */
/*
* Copyright (c) 2011 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -189,6 +189,10 @@ config_setserver(struct httpd *env, struct server *srv)
c = 0;
iov[c].iov_base = &s;
iov[c++].iov_len = sizeof(s);
+ if (srv->srv_conf.return_uri_len != 0) {
+ iov[c].iov_base = srv->srv_conf.return_uri;
+ iov[c++].iov_len = srv->srv_conf.return_uri_len;
+ }
if (srv->srv_conf.tls_cert_len != 0) {
iov[c].iov_base = srv->srv_conf.tls_cert;
iov[c++].iov_len = srv->srv_conf.tls_cert_len;
@@ -246,12 +250,14 @@ config_getserver_config(struct httpd *env, struct server *srv,
struct server_config *srv_conf, *parent;
u_int8_t *p = imsg->data;
u_int f;
+ size_t s;
if ((srv_conf = calloc(1, sizeof(*srv_conf))) == NULL)
return (-1);
IMSG_SIZE_CHECK(imsg, srv_conf);
memcpy(srv_conf, p, sizeof(*srv_conf));
+ s = sizeof(*srv_conf);
/* Reset these variables to avoid free'ing invalid pointers */
serverconfig_reset(srv_conf);
@@ -264,7 +270,7 @@ config_getserver_config(struct httpd *env, struct server *srv,
parent = &srv->srv_conf;
if (config_getserver_auth(env, srv_conf) != 0)
- return (-1);
+ goto fail;
if (srv_conf->flags & SRVFLAG_LOCATION) {
/* Inherit configuration from the parent */
@@ -336,6 +342,24 @@ config_getserver_config(struct httpd *env, struct server *srv,
sizeof(srv_conf->errorlog));
}
+ f = SRVFLAG_BLOCK|SRVFLAG_NO_BLOCK;
+ if ((srv_conf->flags & f) == 0) {
+ srv_conf->flags |= parent->flags & f;
+ srv_conf->return_code = parent->return_code;
+ srv_conf->return_uri_len = parent->return_uri_len;
+ if (srv_conf->return_uri_len &&
+ (srv_conf->return_uri =
+ strdup(parent->return_uri)) == NULL)
+ goto fail;
+ } else {
+ if (srv_conf->return_uri_len != 0) {
+ if ((srv_conf->return_uri = get_data(p + s,
+ srv_conf->return_uri_len)) == NULL)
+ goto fail;
+ s += srv_conf->return_uri_len;
+ }
+ }
+
memcpy(&srv_conf->timeout, &parent->timeout,
sizeof(srv_conf->timeout));
srv_conf->maxrequests = parent->maxrequests;
@@ -358,6 +382,11 @@ config_getserver_config(struct httpd *env, struct server *srv,
TAILQ_INSERT_TAIL(&srv->srv_hosts, srv_conf, entry);
return (0);
+
+ fail:
+ serverconfig_free(srv_conf);
+ free(srv_conf);
+ return (-1);
}
int
@@ -421,6 +450,12 @@ config_getserver(struct httpd *env, struct imsg *imsg)
srv->srv_conf.name, srv->srv_conf.id,
printb_flags(srv->srv_conf.flags, SRVFLAG_BITS));
+ if (srv->srv_conf.return_uri_len != 0) {
+ if ((srv->srv_conf.return_uri = get_data(p + s,
+ srv->srv_conf.return_uri_len)) == NULL)
+ goto fail;
+ s += srv->srv_conf.return_uri_len;
+ }
if (srv->srv_conf.tls_cert_len != 0) {
if ((srv->srv_conf.tls_cert = get_data(p + s,
srv->srv_conf.tls_cert_len)) == NULL)