From: tedu Date: Fri, 16 Oct 2015 18:38:53 +0000 (+0000) Subject: deraadt tells me i'm supposed to check if connect() actually worked. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=292b37a9258f0660b7d5065d3a49be8a708378c8;p=openbsd deraadt tells me i'm supposed to check if connect() actually worked. --- 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 * @@ -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;