diff options
Diffstat (limited to 'zebra/if_netlink.c')
| -rw-r--r-- | zebra/if_netlink.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 8f6e31cfa8..67b6704d6e 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -991,6 +991,12 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup) /* Register interface address to the interface. */ if (ifa->ifa_family == AF_INET) { + if (ifa->ifa_prefixlen > IPV4_MAX_BITLEN) { + zlog_warn( + "Invalid prefix length: %d received from kernel interface addr change: %d", + ifa->ifa_prefixlen, h->nlmsg_type); + return 0; + } if (h->nlmsg_type == RTM_NEWADDR) connected_add_ipv4(ifp, flags, (struct in_addr *)addr, ifa->ifa_prefixlen, @@ -1001,6 +1007,12 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup) ifa->ifa_prefixlen, (struct in_addr *)broad); } if (ifa->ifa_family == AF_INET6) { + if (ifa->ifa_prefixlen > IPV6_MAX_BITLEN) { + zlog_warn( + "Invalid prefix length: %d received from kernel interface addr change: %d", + ifa->ifa_prefixlen, h->nlmsg_type); + return 0; + } if (h->nlmsg_type == RTM_NEWADDR) { /* Only consider valid addresses; we'll not get a * notification from |
