diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-25 15:59:29 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-25 15:59:29 +0000 |
commit | 3234b16c73ae1f8588acec78cf800c5e06ee2122 (patch) | |
tree | 553d84fb9d976c7660e8a3c89c792964d25b8e58 | |
parent | 1ce6c53ecabe2bd8363e47ddff12cc53b5b1e82d (diff) |
At least try to check for the RTM_VERSION here even so part of this code
escaped from a horror story and robs you're sanity. This needs major cleanup.
OK sthen@, OK henning@
-rw-r--r-- | usr.sbin/ppp/ppp/iface.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/route.c | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/usr.sbin/ppp/ppp/iface.c b/usr.sbin/ppp/ppp/iface.c index d56afb5ae88..9d332d48e17 100644 --- a/usr.sbin/ppp/ppp/iface.c +++ b/usr.sbin/ppp/ppp/iface.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: iface.c,v 1.27 2005/07/17 19:13:24 brad Exp $ + * $OpenBSD: iface.c,v 1.28 2009/06/25 15:59:28 claudio Exp $ */ #include <sys/param.h> @@ -140,6 +140,8 @@ iface_Create(const char *name) while (ptr < end && iface == NULL) { ifm = (struct if_msghdr *)ptr; /* On if_msghdr */ + if (ifm->ifm_version != RTM_VERSION) + continue; if (ifm->ifm_type != RTM_IFINFO) break; dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */ @@ -162,6 +164,8 @@ iface_Create(const char *name) if (ifam->ifam_type != RTM_NEWADDR) /* finished this if */ break; + if (ifm->ifm_version != RTM_VERSION) + continue; if (iface != NULL && ifam->ifam_addrs & RTA_IFA) { /* Found a configured interface ! */ diff --git a/usr.sbin/ppp/ppp/route.c b/usr.sbin/ppp/ppp/route.c index f66b6dad2d2..5b644de9028 100644 --- a/usr.sbin/ppp/ppp/route.c +++ b/usr.sbin/ppp/ppp/route.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: route.c,v 1.36 2009/06/05 22:40:24 chris Exp $ + * $OpenBSD: route.c,v 1.37 2009/06/25 15:59:28 claudio Exp $ */ #include <sys/param.h> @@ -250,6 +250,8 @@ Index2Nam(int idx) have = 0; for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) { ifm = (struct if_msghdr *)ptr; + if (ifm->ifm_version != RTM_VERSION) + continue; if (ifm->ifm_type != RTM_IFINFO) continue; dl = (struct sockaddr_dl *)(ifm + 1); @@ -363,6 +365,9 @@ route_Show(struct cmdargs const *arg) for (cp = sp; cp < ep; cp += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)cp; + if (rtm->rtm_version != RTM_VERSION) + continue; + route_ParseHdr(rtm, sa); if (sa[RTAX_DST] && sa[RTAX_GATEWAY]) { @@ -431,6 +436,9 @@ route_IfDelete(struct bundle *bundle, int all) continue; for (cp = sp; cp < ep; cp += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)cp; + if (rtm->rtm_version != RTM_VERSION) + continue; + route_ParseHdr(rtm, sa); if (rtm->rtm_index == bundle->iface->index && sa[RTAX_DST] && sa[RTAX_GATEWAY] && @@ -511,6 +519,8 @@ route_UpdateMTU(struct bundle *bundle) for (cp = sp; cp < ep; cp += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)cp; + if (rtm->rtm_version != RTM_VERSION) + continue; route_ParseHdr(rtm, sa); if (sa[RTAX_DST] && (sa[RTAX_DST]->sa_family == AF_INET #ifndef NOINET6 |