diff options
author | 2015-10-16 18:38:53 +0000 | |
---|---|---|
committer | 2015-10-16 18:38:53 +0000 | |
commit | 292b37a9258f0660b7d5065d3a49be8a708378c8 (patch) | |
tree | c8156075b128f11df0f092fa7bb082bf00755c1d | |
parent | two phase handling for tcp so that slow connects don't stall the process (diff) | |
download | wireguard-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.c | 9 |
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; |