summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2007-09-04 10:58:08 +0000
committerreyk <reyk@openbsd.org>2007-09-04 10:58:08 +0000
commit1c7723840292854477ea72915f1c1cc3a01a03c3 (patch)
treebd5a124daf62935e467f0ecfd8556f089a231a8b
parentsupport chained ssl certificates; a chain can be added to the (diff)
downloadwireguard-openbsd-1c7723840292854477ea72915f1c1cc3a01a03c3.tar.xz
wireguard-openbsd-1c7723840292854477ea72915f1c1cc3a01a03c3.zip
small fix in the error path when accepting new relay sessions
-rw-r--r--usr.sbin/hoststated/relay.c20
-rw-r--r--usr.sbin/relayd/relay.c20
2 files changed, 22 insertions, 18 deletions
diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c
index 6957472a48d..efd7f20e730 100644
--- a/usr.sbin/hoststated/relay.c
+++ b/usr.sbin/hoststated/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.37 2007/09/04 10:32:54 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.38 2007/09/04 10:58:08 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1492,6 +1492,12 @@ relay_accept(int fd, short sig, void *arg)
bcopy(&con->tv_start, &con->tv_last, sizeof(con->tv_last));
bcopy(&ss, &con->in.ss, sizeof(con->in.ss));
+ relay_sessions++;
+ TAILQ_INSERT_HEAD(&rlay->sessions, con, entry);
+
+ /* Increment the per-relay session counter */
+ rlay->stats[proc_id].last++;
+
/* Pre-allocate output buffer */
con->out.output = evbuffer_new();
if (con->out.output == NULL) {
@@ -1508,16 +1514,12 @@ relay_accept(int fd, short sig, void *arg)
if (rlay->conf.flags & F_NATLOOK) {
if ((cnl = (struct ctl_natlook *)
- calloc(1, sizeof(struct ctl_natlook))) == NULL)
- goto err;
+ calloc(1, sizeof(struct ctl_natlook))) == NULL) {
+ relay_close(con, "failed to allocate nat lookup");
+ return;
+ }
}
- relay_sessions++;
- TAILQ_INSERT_HEAD(&rlay->sessions, con, entry);
-
- /* Increment the per-relay session counter */
- rlay->stats[proc_id].last++;
-
if (rlay->conf.flags & F_NATLOOK && cnl != NULL) {
con->cnl = cnl;;
bzero(cnl, sizeof(*cnl));
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 6957472a48d..efd7f20e730 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.37 2007/09/04 10:32:54 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.38 2007/09/04 10:58:08 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1492,6 +1492,12 @@ relay_accept(int fd, short sig, void *arg)
bcopy(&con->tv_start, &con->tv_last, sizeof(con->tv_last));
bcopy(&ss, &con->in.ss, sizeof(con->in.ss));
+ relay_sessions++;
+ TAILQ_INSERT_HEAD(&rlay->sessions, con, entry);
+
+ /* Increment the per-relay session counter */
+ rlay->stats[proc_id].last++;
+
/* Pre-allocate output buffer */
con->out.output = evbuffer_new();
if (con->out.output == NULL) {
@@ -1508,16 +1514,12 @@ relay_accept(int fd, short sig, void *arg)
if (rlay->conf.flags & F_NATLOOK) {
if ((cnl = (struct ctl_natlook *)
- calloc(1, sizeof(struct ctl_natlook))) == NULL)
- goto err;
+ calloc(1, sizeof(struct ctl_natlook))) == NULL) {
+ relay_close(con, "failed to allocate nat lookup");
+ return;
+ }
}
- relay_sessions++;
- TAILQ_INSERT_HEAD(&rlay->sessions, con, entry);
-
- /* Increment the per-relay session counter */
- rlay->stats[proc_id].last++;
-
if (rlay->conf.flags & F_NATLOOK && cnl != NULL) {
con->cnl = cnl;;
bzero(cnl, sizeof(*cnl));