Add sanity check for ifm_version in struct if_msghdr.

This commit is contained in:
Hiroki Sato 2011-07-04 03:19:06 +00:00
parent 1171f21dab
commit adfd20273c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223752

View File

@ -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);