forked from Mirror/frr
*: fix coverity warnings - resource leaks
These are mostly trivial fixes for leaks in the error path of some functions. The changes in bgpd/bgp_mpath.c deserves a bit of explanation though. In the bgp_info_mpath_aggregate_update() function, we were allocating memory for the lcomm variable but doing nothing with it. Since the code for communities, extended communities and large communities is pretty much the same in this function, it's clear that this was a copy and paste error where most of the ext. community code was copied but not all of it as it should have been. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
a1d6bbb1f3
commit
44f12f209f
|
@ -751,6 +751,10 @@ void bgp_info_mpath_aggregate_update(struct bgp_info *new_best,
|
|||
attr.ecommunity = ecomm;
|
||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||
}
|
||||
if (lcomm) {
|
||||
attr.lcommunity = lcomm;
|
||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||
}
|
||||
|
||||
/* Zap multipath attr nexthop so we set nexthop to self */
|
||||
attr.nexthop.s_addr = 0;
|
||||
|
|
|
@ -395,6 +395,7 @@ DEFUN_NOSH(show_hash_stats,
|
|||
pthread_mutex_lock(&_hashes_mtx);
|
||||
if (!_hashes) {
|
||||
pthread_mutex_unlock(&_hashes_mtx);
|
||||
ttable_del(tt);
|
||||
vty_out(vty, "No hash tables in use.\n");
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -101,21 +101,21 @@ static int ripng_make_socket(void)
|
|||
setsockopt_so_recvbuf(sock, 8096);
|
||||
ret = setsockopt_ipv6_pktinfo(sock, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto error;
|
||||
#ifdef IPTOS_PREC_INTERNETCONTROL
|
||||
ret = setsockopt_ipv6_tclass(sock, IPTOS_PREC_INTERNETCONTROL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto error;
|
||||
#endif
|
||||
ret = setsockopt_ipv6_multicast_hops(sock, 255);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto error;
|
||||
ret = setsockopt_ipv6_multicast_loop(sock, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto error;
|
||||
ret = setsockopt_ipv6_hoplimit(sock, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto error;
|
||||
|
||||
memset(&ripaddr, 0, sizeof(ripaddr));
|
||||
ripaddr.sin6_family = AF_INET6;
|
||||
|
@ -132,11 +132,15 @@ static int ripng_make_socket(void)
|
|||
zlog_err("Can't bind ripng socket: %s.", safe_strerror(errno));
|
||||
if (ripngd_privs.change(ZPRIVS_LOWER))
|
||||
zlog_err("ripng_make_socket: could not lower privs");
|
||||
return ret;
|
||||
goto error;
|
||||
}
|
||||
if (ripngd_privs.change(ZPRIVS_LOWER))
|
||||
zlog_err("ripng_make_socket: could not lower privs");
|
||||
return sock;
|
||||
|
||||
error:
|
||||
close(sock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Send RIPng packet. */
|
||||
|
|
|
@ -538,10 +538,7 @@ static void parse_options(int argc, char *const *argv)
|
|||
execname = optarg;
|
||||
break;
|
||||
case 'c': /* --chuid <username>|<uid> */
|
||||
/* we copy the string just in case we need the
|
||||
* argument later. */
|
||||
changeuser = strdup(optarg);
|
||||
changeuser = strtok(changeuser, ":");
|
||||
changeuser = strtok(optarg, ":");
|
||||
changegroup = strtok(NULL, ":");
|
||||
break;
|
||||
case 'r': /* --chroot /new/root */
|
||||
|
|
|
@ -573,6 +573,7 @@ int vtysh_mark_file(const char *filename)
|
|||
* appropriate */
|
||||
if (strlen(vty_buf_trimmed) == 3
|
||||
&& strncmp("end", vty_buf_trimmed, 3) == 0) {
|
||||
cmd_free_strvec(vline);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -804,8 +805,6 @@ static int vtysh_rl_describe(void)
|
|||
} else if (rl_end && isspace((int)rl_line_buffer[rl_end - 1]))
|
||||
vector_set(vline, NULL);
|
||||
|
||||
describe = cmd_describe_command(vline, vty, &ret);
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
/* Ambiguous and no match error. */
|
||||
|
@ -824,6 +823,8 @@ static int vtysh_rl_describe(void)
|
|||
break;
|
||||
}
|
||||
|
||||
describe = cmd_describe_command(vline, vty, &ret);
|
||||
|
||||
/* Get width of command string. */
|
||||
width = 0;
|
||||
for (i = 0; i < vector_active(describe); i++)
|
||||
|
|
|
@ -675,6 +675,7 @@ static int rtadv_make_socket(void)
|
|||
sizeof(struct icmp6_filter));
|
||||
if (ret < 0) {
|
||||
zlog_info("ICMP6_FILTER set fail: %s", safe_strerror(errno));
|
||||
close(sock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue