From 90aa2cef03ff2efa8e9af771632eb3d02d0df168 Mon Sep 17 00:00:00 2001 From: hrs Date: Thu, 16 Jun 2011 12:57:33 +0000 Subject: - Check RTM_VERSION. - Fix WARNS. --- usr.sbin/rtadvd/Makefile | 2 +- usr.sbin/rtadvd/if.c | 6 ++++++ usr.sbin/rtadvd/rtadvd.c | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile index e34aa3c..5afb3bf 100644 --- a/usr.sbin/rtadvd/Makefile +++ b/usr.sbin/rtadvd/Makefile @@ -23,6 +23,6 @@ LDADD= -lutil CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DROUTEINFO -WARNS?= 6 +WARNS?= 3 .include diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c index 302c334..8722a05 100644 --- a/usr.sbin/rtadvd/if.c +++ b/usr.sbin/rtadvd/if.c @@ -105,6 +105,12 @@ if_nametosdl(char *name) lim = buf + len; for (next = buf; next < lim; next += ifm->ifm_msglen) { ifm = (struct if_msghdr *)next; + if (ifm->ifm_version != RTM_VERSION) { + syslog(LOG_ERR, + "<%s> RTM_VERSION mismatch (%d != %d).", + __func__, ifm->ifm_version, RTM_VERSION); + continue; + } if (ifm->ifm_type == RTM_IFINFO) { sa = (struct sockaddr *)(ifm + 1); get_rtaddrs(ifm->ifm_addrs, sa, rti_info); diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index e9b212c..72fb46e 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -503,6 +503,13 @@ rtmsg_input(void) RTADV_TYPE2BITMASK(RTM_IFANNOUNCE)); if (len == 0) break; + if (((struct rt_msghdr *)next)->rtm_version != RTM_VERSION) { + syslog(LOG_ERR, + "<%s> RTM_VERSION mismatch (%d != %d).", + __func__, ((struct rt_msghdr *)next)->rtm_version, + RTM_VERSION); + continue; + } type = rtmsg_type(next); switch (type) { case RTM_ADD: -- cgit v1.1