diff options
| -rw-r--r-- | lib/netns_linux.c | 7 | ||||
| -rw-r--r-- | ospfd/ospf_ase.c | 7 | ||||
| -rw-r--r-- | pimd/mtracebis_netlink.c | 49 | ||||
| -rw-r--r-- | pimd/pim_mroute.c | 2 |
4 files changed, 39 insertions, 26 deletions
diff --git a/lib/netns_linux.c b/lib/netns_linux.c index a3fae8f39f..a80b51fa00 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -435,10 +435,13 @@ char *ns_netns_pathname(struct vty *vty, const char *name) if (!result) { if (vty) - vty_out(vty, "Invalid pathname: %s\n", + vty_out(vty, "Invalid pathname for %s: %s\n", + pathname, safe_strerror(errno)); else - zlog_warn("Invalid pathname: %s", safe_strerror(errno)); + zlog_warn("Invalid pathname for %s: %s", + pathname, + safe_strerror(errno)); return NULL; } check_base = basename(pathname); diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index c799a4b30f..d84fd26ac4 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -543,7 +543,7 @@ static int ospf_ase_route_match_same(struct route_table *rt, struct ospf_route *newor) { struct route_node *rn; - struct ospf_route * or ; + struct ospf_route *or; struct ospf_path *op; struct ospf_path *newop; struct listnode *n1; @@ -559,6 +559,9 @@ static int ospf_ase_route_match_same(struct route_table *rt, route_unlock_node(rn); or = rn->info; + + assert(or); + if (or->path_type != newor->path_type) return 0; @@ -577,6 +580,8 @@ static int ospf_ase_route_match_same(struct route_table *rt, return 0; } + assert(or->paths); + if (or->paths->count != newor->paths->count) return 0; diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c index a66da87e1b..b4bf6bada3 100644 --- a/pimd/mtracebis_netlink.c +++ b/pimd/mtracebis_netlink.c @@ -489,7 +489,6 @@ int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg) int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, void *jarg) { - int status; struct sockaddr_nl nladdr; char buf[8192]; struct nlmsghdr *h = (void *)buf; @@ -500,37 +499,43 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, void *jarg) nladdr.nl_groups = 0; while (1) { - int err, len; - int l; + int err; + size_t l, rl, arl; - status = fread(&buf, 1, sizeof(*h), rtnl); + rl = sizeof(*h); + arl = fread(&buf, 1, rl, rtnl); - if (status < 0) { - if (errno == EINTR) - continue; - perror("rtnl_from_file: fread"); + if (arl != rl) { + if (arl == 0) + return 0; + + if (ferror(rtnl)) + fprintf(stderr, "%s: header read failed\n", + __func__); + else + fprintf(stderr, "%s: truncated header\n", + __func__); return -1; } - if (status == 0) - return 0; - len = h->nlmsg_len; - l = len - sizeof(*h); + l = h->nlmsg_len > rl ? h->nlmsg_len - rl : 0; - if (l < 0 || len > (int)sizeof(buf)) { - fprintf(stderr, "!!!malformed message: len=%d @%lu\n", - len, ftell(rtnl)); + if (l == 0 || (l + (size_t)NLMSG_HDRLEN) > sizeof(buf)) { + fprintf(stderr, "%s: malformed message: len=%zu @%lu\n", + __func__, (size_t)h->nlmsg_len, ftell(rtnl)); return -1; } - status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); + rl = NLMSG_ALIGN(l); + arl = fread(NLMSG_DATA(h), 1, rl, rtnl); - if (status < 0) { - perror("rtnl_from_file: fread"); - return -1; - } - if (status < l) { - fprintf(stderr, "rtnl-from_file: truncated message\n"); + if (arl != rl) { + if (ferror(rtnl)) + fprintf(stderr, "%s: msg read failed\n", + __func__); + else + fprintf(stderr, "%s: truncated message\n", + __func__); return -1; } diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index c7e1a18d28..dd30678405 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -158,7 +158,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, * the Interface type is SSM we don't need to * do anything here */ - if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp) + if (!rpg || (pim_rpf_addr_is_inaddr_none(rpg)) || (!(PIM_I_am_DR(pim_ifp)))) { if (PIM_DEBUG_MROUTE_DETAIL) zlog_debug( |
