diff options
author | 2004-01-26 17:50:53 +0000 | |
---|---|---|
committer | 2004-01-26 17:50:53 +0000 | |
commit | 23d20a0472126fbee16f521cf5d1aa5636f7c467 (patch) | |
tree | 8db6df532c9825386c5fbdf189f219f9149f791a | |
parent | TCP_SIGNATURE enabled by default (diff) | |
download | wireguard-openbsd-23d20a0472126fbee16f521cf5d1aa5636f7c467.tar.xz wireguard-openbsd-23d20a0472126fbee16f521cf5d1aa5636f7c467.zip |
when we error out in send_sa_msg() close the file descriptor.
from Patrick Latifi <pat@eyeo.org>
-rw-r--r-- | usr.sbin/bgpd/pfkey.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/pfkey.c b/usr.sbin/bgpd/pfkey.c index 4804e12cb65..c8b15d98d5f 100644 --- a/usr.sbin/bgpd/pfkey.c +++ b/usr.sbin/bgpd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.1 2004/01/26 14:42:47 henning Exp $ */ +/* $OpenBSD: pfkey.c,v 1.2 2004/01/26 17:50:53 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -53,24 +53,28 @@ send_sa_msg(struct iovec *iov, int cnt, int len) if ((n = writev(sd, iov, cnt)) == -1) { log_warn("write"); + close(sd); return (-1); } if (n != len) { log_warn("writev: should=%d has=%d", len, n); + close(sd); return (-1); } if (read(sd, &sm, sizeof(sm)) != sizeof(sm)) { log_warn("read"); + close(sd); return (-1); } + close(sd); + if (sm.sadb_msg_errno != 0) { errno = sm.sadb_msg_errno; log_warn("pfkey"); return (-1); } - close(sd); return (0); } |