diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-26 17:50:54 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-26 17:50:54 +0000 |
commit | ca8f5f20d054c18bc2d7275db08df00811260f84 (patch) | |
tree | f12bf6ae57588011f94e2a60268f5fcaf9a21844 /usr.sbin/bgpd | |
parent | 96a371a34fde5533765b359d90490593e2a3d049 (diff) |
when we error out in send_sa_msg() close the file descriptor.
from Patrick Latifi <pat@eyeo.org>
Diffstat (limited to 'usr.sbin/bgpd')
-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); } |