ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
+ if (ip_hlen > len) {
+ zlog_warn(
+ "IGMP packet header claims size %zu, but we only have %zu bytes",
+ ip_hlen, len);
+ return -1;
+ }
+
igmp_msg = buf + ip_hlen;
- msg_type = *igmp_msg;
igmp_msg_len = len - ip_hlen;
+ if (igmp_msg_len < PIM_IGMP_MIN_LEN) {
+ zlog_warn("IGMP message size=%d shorter than minimum=%d",
+ igmp_msg_len, PIM_IGMP_MIN_LEN);
+ return -1;
+ }
+
+ msg_type = *igmp_msg;
+
if (PIM_DEBUG_IGMP_PACKETS) {
zlog_debug(
"Recv IGMP packet from %s to %s on %s: size=%zu ttl=%d msg_type=%d msg_size=%d",
msg_type, igmp_msg_len);
}
- if (igmp_msg_len < PIM_IGMP_MIN_LEN) {
- zlog_warn("IGMP message size=%d shorter than minimum=%d",
- igmp_msg_len, PIM_IGMP_MIN_LEN);
- return -1;
- }
-
switch (msg_type) {
case PIM_IGMP_MEMBERSHIP_QUERY: {
int max_resp_code = igmp_msg[1];
}
if (pim_is_group_224_0_0_0_24(group_addr)) {
- zlog_warn("%s: Group specified is part of 224.0.0.0/24",
- __PRETTY_FUNCTION__);
+ if (PIM_DEBUG_IGMP_TRACE)
+ zlog_debug(
+ "%s: Group specified %s is part of 224.0.0.0/24",
+ __PRETTY_FUNCTION__, inet_ntoa(group_addr));
return NULL;
}
/*