From: Donald Sharp Date: Thu, 1 Dec 2016 22:12:21 +0000 (-0500) Subject: pimd: Don't allow invalid groups to be passed for igmp X-Git-Tag: frr-3.0-branchpoint~64^2~10^2~46 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b815998a4296c6e7ce12faa37eaff0d7d0f697d7;p=mirror%2Ffrr.git pimd: Don't allow invalid groups to be passed for igmp When we receive a invalid group( say outside of the 224/4 range) don't allow it to create state. Nicely reject the rejectable. Ticket: CM-13821 Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 87a54d68d0..1ca79a5a54 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -1050,6 +1050,13 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp, return group; } + if (!pim_is_group_224_4 (group_addr)) + { + zlog_warn("%s: Group Specified is not part of 224.0.0.0/4", + __PRETTY_FUNCTION__); + return NULL; + } + /* Non-existant group is created as INCLUDE {empty}: @@ -1067,7 +1074,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp, if (!group) { zlog_warn("%s %s: XCALLOC() failure", __FILE__, __PRETTY_FUNCTION__); - return 0; /* error, not found, could not create */ + return NULL; /* error, not found, could not create */ } group->group_source_list = list_new(); @@ -1075,7 +1082,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp, zlog_warn("%s %s: list_new() failure", __FILE__, __PRETTY_FUNCTION__); XFREE(MTYPE_PIM_IGMP_GROUP, group); /* discard group */ - return 0; /* error, not found, could not initialize */ + return NULL; /* error, not found, could not initialize */ } group->group_source_list->del = (void (*)(void *)) igmp_source_free; diff --git a/pimd/pim_util.c b/pimd/pim_util.c index daee941f8b..f5255a241d 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -22,6 +22,7 @@ #include #include "log.h" +#include "prefix.h" #include "pim_util.h" @@ -104,3 +105,20 @@ void pim_pkt_dump(const char *label, const uint8_t *buf, int size) size); zlog_hexdump(buf, size); } + +int +pim_is_group_224_4 (struct in_addr group_addr) +{ + static int first = 1; + static struct prefix group_all; + struct prefix group; + + if (first) + str2prefix ("224.0.0.0/4", &group_all); + + group.family = AF_INET; + group.u.prefix4 = group_addr; + group.prefixlen = 32; + + return prefix_match (&group_all, &group); +} diff --git a/pimd/pim_util.h b/pimd/pim_util.h index 23a9688647..a948f81ce8 100644 --- a/pimd/pim_util.h +++ b/pimd/pim_util.h @@ -33,4 +33,5 @@ uint16_t igmp_msg_decode8to16(uint8_t code); void pim_pkt_dump(const char *label, const uint8_t *buf, int size); +int pim_is_group_224_4 (struct in_addr group_addr); #endif /* PIM_UTIL_H */