]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncation 2385/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 7 Jun 2018 23:51:13 +0000 (19:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 7 Jun 2018 23:51:13 +0000 (19:51 -0400)
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>
bgpd/bgp_flowspec.c
bgpd/bgp_route.c
lib/libfrr.c
lib/libfrr.h
lib/module.c
ospf6d/ospf6_neighbor.h
vtysh/vtysh_main.c

index 6eb1e39884d386233a7ecd6e2f1a762fae213dd5..884c5aa51a182aab9ae5360a027b7bb4b810ba63 100644 (file)
@@ -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,
index 0e99bcbb14c2d1acfbb1e340671fba0c181b0932..a60543cabe8cc7b3ea22561ae504c18a48a8d329 100644 (file)
@@ -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];
 
index 99311836340993adf117da00a7367014c9254d25..88203fbeb6bb57e424d5a1a2a5bfbd7db0d78fd2 100644 (file)
@@ -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;
index fe6c46670a3c6b312cb83fcd59b535a0d7f3c623..7ffa780bfb9a75d8d6316a0b73d564d9399650d4 100644 (file)
@@ -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[];
index 3f13307d82c266b7f2ddf2162f46ebf8abd5c9a0..0c853640035a9c34d7aca1e1056e597513b51bc3 100644 (file)
@@ -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;
 
index 0c4926edbb4bc9d0614f9a9a5e6cb74f943d96fe..840683cc2f37fab76c2e4d31ba9f339f7535b429 100644 (file)
@@ -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;
index ff5e6bb7842062b59aec257a444641800a62e7c4..ad7d072d3daa7430983aac4de233a9a0dd82bd6a 100644 (file)
@@ -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];