diff options
author | dfr <dfr@FreeBSD.org> | 1995-01-30 11:11:43 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1995-01-30 11:11:43 +0000 |
commit | 48859413cdeec6161df494fba1da66bead5b8ee3 (patch) | |
tree | f7c0442786190552d5019cf6030f8b593c99682b /libexec/bootpd | |
parent | 426a9a3688b05e3438179bc0049b5efefd88993d (diff) | |
download | FreeBSD-src-48859413cdeec6161df494fba1da66bead5b8ee3.zip FreeBSD-src-48859413cdeec6161df494fba1da66bead5b8ee3.tar.gz |
Discard any messages which are buffered on the routing socket before using
it otherwise the response to one of our routing messages could be lost due
to buffer overflow.
Diffstat (limited to 'libexec/bootpd')
-rw-r--r-- | libexec/bootpd/rtmsg.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libexec/bootpd/rtmsg.c b/libexec/bootpd/rtmsg.c index 7d0e8f4..41b8273 100644 --- a/libexec/bootpd/rtmsg.c +++ b/libexec/bootpd/rtmsg.c @@ -39,7 +39,7 @@ /* * from arp.c 8.2 (Berkeley) 1/2/94 - * $Id: rtmsg.c,v 1.1.1.1 1994/09/30 05:45:06 pst Exp $ + * $Id: rtmsg.c,v 1.2 1995/01/16 18:57:45 dfr Exp $ */ #include <sys/param.h> @@ -50,6 +50,7 @@ #if BSD >= 199306 #include <sys/socket.h> +#include <sys/filio.h> #include <net/if.h> #include <net/if_dl.h> @@ -85,6 +86,18 @@ static void getsocket () { report(LOG_ERR, "socket %s", strerror(errno)); exit(1); } + } else { + /* + * Drain the socket of any unwanted routing messages. + */ + int n; + char buf[512]; + + ioctl(s, FIONREAD, &n); + while (n > 0) { + read(s, buf, sizeof buf); + ioctl(s, FIONREAD, &n); + } } } @@ -228,7 +241,7 @@ static int rtmsg(cmd) } do { l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg)); - } while (l > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != getpid())); + } while (l > 0 && (rtm->rtm_type != cmd || rtm->rtm_seq != seq || rtm->rtm_pid != getpid())); if (l < 0) report(LOG_WARNING, "arp: read from routing socket: %s\n", strerror(errno)); |