diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-08 01:51:13 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-08 01:51:13 +0200 |
commit | ff44f570144407f6bcc1ef205759f7c9fa57e077 (patch) | |
tree | cbb04ec29d3e93f4cae6af639500b49238e07cc2 | |
parent | vtysh, zebra: Fix function parameters (diff) | |
download | frr-ff44f570144407f6bcc1ef205759f7c9fa57e077.tar.xz frr-ff44f570144407f6bcc1ef205759f7c9fa57e077.zip |
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>
-rw-r--r-- | bgpd/bgp_flowspec.c | 9 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 6 | ||||
-rw-r--r-- | lib/libfrr.c | 4 | ||||
-rw-r--r-- | lib/libfrr.h | 2 | ||||
-rw-r--r-- | lib/module.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_neighbor.h | 2 | ||||
-rw-r--r-- | vtysh/vtysh_main.c | 4 |
7 files changed, 14 insertions, 15 deletions
diff --git a/bgpd/bgp_flowspec.c b/bgpd/bgp_flowspec.c index 6eb1e3988..884c5aa51 100644 --- a/bgpd/bgp_flowspec.c +++ b/bgpd/bgp_flowspec.c @@ -148,7 +148,7 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, if (BGP_DEBUG(flowspec, FLOWSPEC)) { 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 *s = NULL; @@ -157,20 +157,19 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, p.u.prefix_flowspec.prefixlen, return_string, NLRI_STRING_FORMAT_MIN, NULL); - snprintf(ec_string, BGP_FLOWSPEC_NLRI_STRING_MAX, + snprintf(ec_string, sizeof(ec_string), "EC{none}"); if (attr && attr->ecommunity) { s = ecommunity_ecom2str(attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - snprintf(ec_string, - BGP_FLOWSPEC_NLRI_STRING_MAX, + snprintf(ec_string, sizeof(ec_string), "EC{%s}", s == NULL ? "none" : s); if (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 ? "Withdraw":"Update", afi2str(afi), return_string, diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0e99bcbb1..a60543cab 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7063,8 +7063,8 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p, || (safi == SAFI_EVPN && BGP_ATTR_NEXTHOP_AFI_IP6(attr)) || (BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { - char buf_a[BUFSIZ]; - char buf_b[BUFSIZ]; + char buf_a[512]; + char buf_b[512]; char buf_c[BUFSIZ]; if (attr->mp_nexthop_len == 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_rd *prd; struct bgp_static *bgp_static; - char buf[PREFIX_STRLEN]; + char buf[PREFIX_STRLEN * 2]; char buf2[SU_ADDRSTRLEN]; char rdbuf[RD_ADDRSTRLEN]; diff --git a/lib/libfrr.c b/lib/libfrr.c index 993118363..88203fbeb 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -47,9 +47,9 @@ const char frr_moduledir[] = MODULE_PATH; char frr_protoname[256] = "NONE"; char frr_protonameinst[256] = "NONE"; -char config_default[256]; +char config_default[512]; char frr_zclientpath[256]; -static char pidfile_default[256]; +static char pidfile_default[512]; static char vtypath_default[256]; bool debug_memstats_at_exit = 0; diff --git a/lib/libfrr.h b/lib/libfrr.h index fe6c46670..7ffa780bf 100644 --- a/lib/libfrr.h +++ b/lib/libfrr.h @@ -113,7 +113,7 @@ extern void frr_early_fini(void); DECLARE_KOOH(frr_fini, (), ()) extern void frr_fini(void); -extern char config_default[256]; +extern char config_default[512]; extern char frr_zclientpath[256]; extern const char frr_sysconfdir[]; extern const char frr_vtydir[]; diff --git a/lib/module.c b/lib/module.c index 3f13307d8..0c8536400 100644 --- a/lib/module.c +++ b/lib/module.c @@ -75,7 +75,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err, size_t err_len) { 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; const struct frrmod_info *info; diff --git a/ospf6d/ospf6_neighbor.h b/ospf6d/ospf6_neighbor.h index 0c4926edb..840683cc2 100644 --- a/ospf6d/ospf6_neighbor.h +++ b/ospf6d/ospf6_neighbor.h @@ -35,7 +35,7 @@ extern unsigned char conf_debug_ospf6_neighbor; /* Neighbor structure */ struct ospf6_neighbor { /* Neighbor Router ID String */ - char name[32]; + char name[36]; /* OSPFv3 Interface this neighbor belongs to */ struct ospf6_interface *ospf6_if; diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index ff5e6bb78..ad7d072d3 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -52,8 +52,8 @@ static gid_t elevgid, realgid; #define FRR_CONFIG_NAME "frr.conf" /* Configuration file name and directory. */ -static char vtysh_config[MAXPATHLEN]; -char frr_config[MAXPATHLEN]; +static char vtysh_config[MAXPATHLEN * 3]; +char frr_config[MAXPATHLEN * 3]; char vtydir[MAXPATHLEN]; static char history_file[MAXPATHLEN]; |