diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2012-07-11 09:43:11 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2012-07-11 09:43:11 +0000 |
commit | ec5a5808178841e2ba2ba3b8542340bfede603b2 (patch) | |
tree | 2beebd3196c408042220edbe685d92a118129e50 /usr.sbin | |
parent | de65d75fddef912dd9d853633af368812c9cfc4e (diff) |
Limit "while(setsockopt(..SO_RCVBUF/SO_SNDBUF..))" loops to prevent them
running away if the setsockopt call fails, as may happen if a peer bounces
at the wrong time.
OK claudio@ after tweaks to an earlier version which was OK phessler@.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/session.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 8a511339e4e..22d863be1ec 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.322 2012/07/09 11:11:07 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.323 2012/07/11 09:43:10 sthen Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -1211,12 +1211,14 @@ session_setup_socket(struct peer *p) if (p->conf.auth.method != AUTH_NONE) { /* try to increase bufsize. no biggie if it fails */ bsize = 65535; - while (setsockopt(p->fd, SOL_SOCKET, SO_RCVBUF, &bsize, - sizeof(bsize)) == -1) + while (bsize > 8192 && + setsockopt(p->fd, SOL_SOCKET, SO_RCVBUF, &bsize, + sizeof(bsize)) == -1 && errno != EINVAL) bsize /= 2; bsize = 65535; - while (setsockopt(p->fd, SOL_SOCKET, SO_SNDBUF, &bsize, - sizeof(bsize)) == -1) + while (bsize > 8192 && + setsockopt(p->fd, SOL_SOCKET, SO_SNDBUF, &bsize, + sizeof(bsize)) == -1 && errno != EINVAL) bsize /= 2; } |