Merge pull request #700 "Coverity high"

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-06-13 10:05:51 +02:00
commit 063221b5ad
8 changed files with 40 additions and 20 deletions

View File

@ -451,6 +451,7 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf)
/* TODO: handle IPv6 nexthops */
zlog_warn ("%s: %s: invalid MP nexthop length (AFI IP): %u",
__func__, peer->host, nhlen);
stream_free (s);
return NULL;
}
@ -542,6 +543,7 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf)
/* TODO: handle IPv4 nexthops */
zlog_warn ("%s: %s: invalid MP nexthop length (AFI IP6): %u",
__func__, peer->host, nhlen);
stream_free (s);
return NULL;
}

View File

@ -51,14 +51,14 @@
/* Enable debug option variables -- valid only session. */
unsigned long term_debug_eigrp = 0;
unsigned long term_debug_eigrp_nei = 0;
unsigned long term_debug_eigrp_packet[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long term_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long term_debug_eigrp_zebra = 6;
unsigned long term_debug_eigrp_transmit = 0;
/* Configuration debug option variables. */
unsigned long conf_debug_eigrp = 0;
unsigned long conf_debug_eigrp_nei = 0;
unsigned long conf_debug_eigrp_packet[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long conf_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long conf_debug_eigrp_zebra = 0;
unsigned long conf_debug_eigrp_transmit = 0;

View File

@ -122,7 +122,7 @@ eigrp_hello_timer (struct thread *thread)
* Note the addition of K6 for the new extended metrics, and does not apply to
* older TLV packet formats.
*/
static void
static struct eigrp_neighbor *
eigrp_hello_parameter_decode (struct eigrp_neighbor *nbr,
struct eigrp_tlv_hdr_type *tlv)
{
@ -172,6 +172,7 @@ eigrp_hello_parameter_decode (struct eigrp_neighbor *nbr,
zlog_info ("Neighbor %s (%s) is down: Interface PEER-TERMINATION received",
inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
eigrp_nbr_delete (nbr);
return NULL;
}
else
{
@ -181,6 +182,8 @@ eigrp_hello_parameter_decode (struct eigrp_neighbor *nbr,
}
}
}
return nbr;
}
static u_char
@ -349,7 +352,9 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
switch (type)
{
case EIGRP_TLV_PARAMETER:
eigrp_hello_parameter_decode(nbr, tlv_header);
nbr = eigrp_hello_parameter_decode(nbr, tlv_header);
if (!nbr)
return;
break;
case EIGRP_TLV_AUTH:
{

View File

@ -291,13 +291,13 @@ eigrp_if_up (struct eigrp_interface *ei)
/*Add connected entry to topology table*/
struct prefix_ipv4 *dest_addr = prefix_ipv4_new ();
struct prefix_ipv4 dest_addr;
dest_addr->family = AF_INET;
dest_addr->prefix = ei->connected->address->u.prefix4;
dest_addr->prefixlen = ei->connected->address->prefixlen;
apply_mask_ipv4 (dest_addr);
pe = eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, dest_addr);
dest_addr.family = AF_INET;
dest_addr.prefix = ei->connected->address->u.prefix4;
dest_addr.prefixlen = ei->connected->address->prefixlen;
apply_mask_ipv4 (&dest_addr);
pe = eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, &dest_addr);
if (pe == NULL)
{
@ -305,7 +305,7 @@ eigrp_if_up (struct eigrp_interface *ei)
pe->serno = eigrp->serno;
pe->destination_ipv4 = prefix_ipv4_new ();
prefix_copy ((struct prefix *)pe->destination_ipv4,
(struct prefix *)dest_addr);
(struct prefix *)&dest_addr);
pe->af = AF_INET;
pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;

View File

@ -185,7 +185,7 @@ eigrp_check_md5_digest (struct stream *s,
eigrph->checksum = 0;
auth_TLV =(struct TLV_MD5_Authentication_Type *) (s->data + EIGRP_HEADER_LEN);
memcpy(auth_TLV->digest, "0", sizeof(auth_TLV->digest));
memset(auth_TLV->digest, 0, sizeof(auth_TLV->digest));
ibuf = s->data;
backup_end = s->endp;

View File

@ -160,6 +160,7 @@ eigrp_send_query (struct eigrp_interface *ei)
struct eigrp_neighbor *nbr;
struct eigrp_prefix_entry *pe;
char has_tlv;
bool ep_saved = false;
ep = eigrp_packet_new(ei->ifp->mtu);
@ -218,6 +219,7 @@ eigrp_send_query (struct eigrp_interface *ei)
{
/*Put packet to retransmission queue*/
eigrp_fifo_push_head(nbr->retrans_queue, ep);
ep_saved = true;
if (nbr->retrans_queue->count == 1)
{
@ -225,4 +227,7 @@ eigrp_send_query (struct eigrp_interface *ei)
}
}
}
if (!ep_saved)
eigrp_packet_free(ep);
}

View File

@ -307,6 +307,8 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h,
p.family = AF_INET;
memcpy (&p.u.prefix4, dest, 4);
p.prefixlen = rtm->rtm_dst_len;
src_p.prefixlen = 0; // Forces debug below to not display anything
}
else if (rtm->rtm_family == AF_INET6)
{

View File

@ -740,7 +740,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out (vty, " %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
if (nexthop->ifindex)
vty_out (vty, ", via %s",
ifindex2ifname (nexthop->ifindex, re->vrf_id));
@ -793,7 +793,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
{
vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
nexthop->nh_label->label, buf, BUFSIZ, 1));
nexthop->nh_label->label, buf, sizeof buf, 1));
}
vty_out (vty, "%s", VTY_NEWLINE);
@ -890,7 +890,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
json_object_string_add(json_nexthop, "ip", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
json_object_string_add(json_nexthop, "ip", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
json_object_string_add(json_nexthop, "afi", "ipv6");
if (nexthop->ifindex)
@ -1001,7 +1001,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out (vty, " via %s",
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
if (nexthop->ifindex)
vty_out (vty, ", %s",
ifindex2ifname (nexthop->ifindex, re->vrf_id));
@ -1053,7 +1053,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r
{
vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
nexthop->nh_label->label, buf, BUFSIZ, 1));
nexthop->nh_label->label, buf, sizeof buf, 1));
}
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
@ -1929,7 +1929,7 @@ static_config (struct vty *vty, afi_t afi, safi_t safi, const char *cmd)
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
break;
case STATIC_IPV6_GATEWAY:
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, sizeof buf));
break;
case STATIC_IFINDEX:
vty_out (vty, " %s", si->ifname);
@ -1939,7 +1939,7 @@ static_config (struct vty *vty, afi_t afi, safi_t safi, const char *cmd)
break;
case STATIC_IPV6_GATEWAY_IFINDEX:
vty_out (vty, " %s %s",
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
inet_ntop (AF_INET6, &si->addr.ipv6, buf, sizeof buf),
ifindex2ifname (si->ifindex, si->vrf_id));
break;
}
@ -3098,6 +3098,8 @@ DEFUN (ip_zebra_import_table_distance,
int distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
char *rmap = strmatch (argv[argc - 2]->text, "route-map") ?
XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[argc - 1]->arg) : NULL;
int ret;
if (argc == 7 || (argc == 5 && !rmap))
VTY_GET_INTEGER_RANGE("distance", distance, argv[4]->arg, 1, 255);
@ -3115,7 +3117,11 @@ DEFUN (ip_zebra_import_table_distance,
return CMD_WARNING;
}
return (zebra_import_table(AFI_IP, table_id, distance, rmap, 1));
ret = zebra_import_table(AFI_IP, table_id, distance, rmap, 1);
if (rmap)
XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
return ret;
}
DEFUN (no_ip_zebra_import_table,