diff options
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.c | 5 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpe.c | 5 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/kroute.c | 13 |
3 files changed, 16 insertions, 7 deletions
diff --git a/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c index 21b8a24a963..6a6f2f791f0 100644 --- a/usr.sbin/dvmrpd/dvmrpd.c +++ b/usr.sbin/dvmrpd/dvmrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.c,v 1.18 2015/02/09 11:45:22 claudio Exp $ */ +/* $OpenBSD: dvmrpd.c,v 1.19 2015/02/10 08:49:30 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -221,7 +221,8 @@ main(int argc, char *argv[]) pipe_parent2rde); /* create the raw ip socket */ - if ((conf->mroute_socket = socket(AF_INET, SOCK_RAW, + if ((conf->mroute_socket = socket(AF_INET, + SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_IGMP)) == -1) fatal("error creating raw socket"); diff --git a/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c index d391396ca1e..0059aaea1ff 100644 --- a/usr.sbin/dvmrpd/dvmrpe.c +++ b/usr.sbin/dvmrpd/dvmrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.c,v 1.13 2014/11/18 20:54:28 krw Exp $ */ +/* $OpenBSD: dvmrpe.c,v 1.14 2015/02/10 08:49:30 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -85,7 +85,8 @@ dvmrpe(struct dvmrpd_conf *xconf, int pipe_parent2dvmrpe[2], } /* create the raw ip socket */ - if ((xconf->dvmrp_socket = socket(AF_INET, SOCK_RAW, + if ((xconf->dvmrp_socket = socket(AF_INET, + SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_IGMP)) == -1) fatal("error creating raw socket"); diff --git a/usr.sbin/dvmrpd/kroute.c b/usr.sbin/dvmrpd/kroute.c index f90a2b2c642..07068d2723e 100644 --- a/usr.sbin/dvmrpd/kroute.c +++ b/usr.sbin/dvmrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.9 2015/01/16 06:40:16 deraadt Exp $ */ +/* $OpenBSD: kroute.c,v 1.10 2015/02/10 08:49:30 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -84,7 +84,8 @@ kr_init(void) { int opt, fd; - if ((fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) { + if ((fd = socket(AF_ROUTE, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, + 0)) == -1) { log_warn("kr_init: socket"); return (-1); } @@ -376,8 +377,11 @@ kr_dispatch_msg(int fd, short event, void *bula) struct rt_msghdr *rtm; struct if_msghdr ifm; - if ((n = read(fd, &buf, sizeof(buf))) == -1) + if ((n = read(fd, &buf, sizeof(buf))) == -1) { + if (errno == EAGAIN || errno == EINTR) + return; fatal("dispatch_rtmsg: read error"); + } if (n == 0) fatalx("routing socket closed"); @@ -385,6 +389,9 @@ kr_dispatch_msg(int fd, short event, void *bula) lim = buf + n; for (next = buf; next < lim; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)next; + if (lim < next + sizeof(*rtm) || + lim < next + rtm->rtm_msglen) + fatalx("dispatch_rtmsg: partial rtm in buffer"); if (rtm->rtm_version != RTM_VERSION) continue; |