summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-10-16 18:38:53 +0000
committertedu <tedu@openbsd.org>2015-10-16 18:38:53 +0000
commit292b37a9258f0660b7d5065d3a49be8a708378c8 (patch)
treec8156075b128f11df0f092fa7bb082bf00755c1d
parenttwo phase handling for tcp so that slow connects don't stall the process (diff)
downloadwireguard-openbsd-292b37a9258f0660b7d5065d3a49be8a708378c8.tar.xz
wireguard-openbsd-292b37a9258f0660b7d5065d3a49be8a708378c8.zip
deraadt tells me i'm supposed to check if connect() actually worked.
-rw-r--r--usr.sbin/rebound/rebound.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/rebound/rebound.c b/usr.sbin/rebound/rebound.c
index 8c8a67ac2db..e6ed797f158 100644
--- a/usr.sbin/rebound/rebound.c
+++ b/usr.sbin/rebound/rebound.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rebound.c,v 1.21 2015/10/16 18:29:05 tedu Exp $ */
+/* $OpenBSD: rebound.c,v 1.22 2015/10/16 18:38:53 tedu Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
@@ -269,7 +269,14 @@ freecacheent(struct dnscache *ent)
static struct request *
tcpphasetwo(struct request *req)
{
+ int error;
+ socklen_t len = sizeof(error);
+
req->phase = 2;
+
+ if (getsockopt(req->s, SOL_SOCKET, SO_ERROR, &error, &len) == -1 ||
+ error != 0)
+ goto fail;
if (setsockopt(req->client, SOL_SOCKET, SO_SPLICE, &req->s,
sizeof(req->s)) == -1)
goto fail;