bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncation

With a new version of clang 6.0, the compiler is detecting more
issues where we may be possibly be truncating the output string.
Fix by increasing the size of the output string to make the compiler
happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-06-07 19:51:13 -04:00
parent b1599bb6f4
commit ff44f57014
7 changed files with 14 additions and 15 deletions

View File

@ -148,7 +148,7 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
if (BGP_DEBUG(flowspec, FLOWSPEC)) { if (BGP_DEBUG(flowspec, FLOWSPEC)) {
char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX];
char local_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; char local_string[BGP_FLOWSPEC_NLRI_STRING_MAX * 2];
char ec_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; char ec_string[BGP_FLOWSPEC_NLRI_STRING_MAX];
char *s = NULL; char *s = NULL;
@ -157,20 +157,19 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
p.u.prefix_flowspec.prefixlen, p.u.prefix_flowspec.prefixlen,
return_string, return_string,
NLRI_STRING_FORMAT_MIN, NULL); NLRI_STRING_FORMAT_MIN, NULL);
snprintf(ec_string, BGP_FLOWSPEC_NLRI_STRING_MAX, snprintf(ec_string, sizeof(ec_string),
"EC{none}"); "EC{none}");
if (attr && attr->ecommunity) { if (attr && attr->ecommunity) {
s = ecommunity_ecom2str(attr->ecommunity, s = ecommunity_ecom2str(attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0); ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
snprintf(ec_string, snprintf(ec_string, sizeof(ec_string),
BGP_FLOWSPEC_NLRI_STRING_MAX,
"EC{%s}", "EC{%s}",
s == NULL ? "none" : s); s == NULL ? "none" : s);
if (s) if (s)
ecommunity_strfree(&s); ecommunity_strfree(&s);
} }
snprintf(local_string, BGP_FLOWSPEC_NLRI_STRING_MAX, snprintf(local_string, sizeof(local_string),
"FS Rx %s %s %s %s", withdraw ? "FS Rx %s %s %s %s", withdraw ?
"Withdraw":"Update", "Withdraw":"Update",
afi2str(afi), return_string, afi2str(afi), return_string,

View File

@ -7063,8 +7063,8 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p,
|| (safi == SAFI_EVPN || (safi == SAFI_EVPN
&& BGP_ATTR_NEXTHOP_AFI_IP6(attr)) && BGP_ATTR_NEXTHOP_AFI_IP6(attr))
|| (BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { || (BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
char buf_a[BUFSIZ]; char buf_a[512];
char buf_b[BUFSIZ]; char buf_b[512];
char buf_c[BUFSIZ]; char buf_c[BUFSIZ];
if (attr->mp_nexthop_len if (attr->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL) { == BGP_ATTR_NHLEN_IPV6_GLOBAL) {
@ -11421,7 +11421,7 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
struct prefix *p; struct prefix *p;
struct prefix_rd *prd; struct prefix_rd *prd;
struct bgp_static *bgp_static; struct bgp_static *bgp_static;
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN * 2];
char buf2[SU_ADDRSTRLEN]; char buf2[SU_ADDRSTRLEN];
char rdbuf[RD_ADDRSTRLEN]; char rdbuf[RD_ADDRSTRLEN];

View File

@ -47,9 +47,9 @@ const char frr_moduledir[] = MODULE_PATH;
char frr_protoname[256] = "NONE"; char frr_protoname[256] = "NONE";
char frr_protonameinst[256] = "NONE"; char frr_protonameinst[256] = "NONE";
char config_default[256]; char config_default[512];
char frr_zclientpath[256]; char frr_zclientpath[256];
static char pidfile_default[256]; static char pidfile_default[512];
static char vtypath_default[256]; static char vtypath_default[256];
bool debug_memstats_at_exit = 0; bool debug_memstats_at_exit = 0;

View File

@ -113,7 +113,7 @@ extern void frr_early_fini(void);
DECLARE_KOOH(frr_fini, (), ()) DECLARE_KOOH(frr_fini, (), ())
extern void frr_fini(void); extern void frr_fini(void);
extern char config_default[256]; extern char config_default[512];
extern char frr_zclientpath[256]; extern char frr_zclientpath[256];
extern const char frr_sysconfdir[]; extern const char frr_sysconfdir[];
extern const char frr_vtydir[]; extern const char frr_vtydir[];

View File

@ -75,7 +75,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,
size_t err_len) size_t err_len)
{ {
void *handle = NULL; void *handle = NULL;
char name[PATH_MAX], fullpath[PATH_MAX], *args; char name[PATH_MAX], fullpath[PATH_MAX * 2], *args;
struct frrmod_runtime *rtinfo, **rtinfop; struct frrmod_runtime *rtinfo, **rtinfop;
const struct frrmod_info *info; const struct frrmod_info *info;

View File

@ -35,7 +35,7 @@ extern unsigned char conf_debug_ospf6_neighbor;
/* Neighbor structure */ /* Neighbor structure */
struct ospf6_neighbor { struct ospf6_neighbor {
/* Neighbor Router ID String */ /* Neighbor Router ID String */
char name[32]; char name[36];
/* OSPFv3 Interface this neighbor belongs to */ /* OSPFv3 Interface this neighbor belongs to */
struct ospf6_interface *ospf6_if; struct ospf6_interface *ospf6_if;

View File

@ -52,8 +52,8 @@ static gid_t elevgid, realgid;
#define FRR_CONFIG_NAME "frr.conf" #define FRR_CONFIG_NAME "frr.conf"
/* Configuration file name and directory. */ /* Configuration file name and directory. */
static char vtysh_config[MAXPATHLEN]; static char vtysh_config[MAXPATHLEN * 3];
char frr_config[MAXPATHLEN]; char frr_config[MAXPATHLEN * 3];
char vtydir[MAXPATHLEN]; char vtydir[MAXPATHLEN];
static char history_file[MAXPATHLEN]; static char history_file[MAXPATHLEN];