]> git.proxmox.com Git - mirror_frr.git/commitdiff
pbrd: Fix compilation warn -> error
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 15 May 2018 17:34:52 +0000 (13:34 -0400)
committerMartin Winter <mwinter@opensourcerouting.org>
Mon, 4 Jun 2018 00:21:20 +0000 (17:21 -0700)
The buffer size was insufficiently sized to hold the
entirety of the data being passed in.

Modify the nht code to use a bit bigger buffer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pbrd/pbr_nht.c
pbrd/pbr_nht.h
pbrd/pbr_vty.c

index 5be96e86d00c030abd80036423b86586493e8941..a4a9233f72a138a94267e42edc4225adee79bf03 100644 (file)
@@ -470,18 +470,6 @@ void pbr_nht_change_group(const char *name)
        pbr_nht_install_nexthop_group(pnhgc, nhgc->nhg);
 }
 
-/*
- * Since we are writing into the name field which is PBR_MAP_NAMELEN
- * size, we are expecting this to field to be at max 100 bytes.
- * Newer compilers understand that the %s portion may be up to
- * 100 bytes( because of the size of the string.  The %u portion
- * is expected to be 10 bytes.  So in `theory` there are situations
- * where we might truncate.  The reality this is never going to
- * happen( who is going to create a nexthop group name that is
- * over say 30 characters? ).  As such we are expecting the
- * calling function to subtract 10 from the size_t l before
- * we pass it in to get around this new gcc fun.
- */
 char *pbr_nht_nexthop_make_name(char *name, size_t l,
                                uint32_t seqno, char *buffer)
 {
@@ -497,7 +485,7 @@ void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms)
        struct pbr_nexthop_cache lookup;
 
        memset(&find, 0, sizeof(find));
-       pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_MAP_NAMELEN - 10,
+       pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_NHC_NAMELEN,
                                  pbrms->seqno, find.name);
        if (!pbrms->internal_nhg_name)
                pbrms->internal_nhg_name = XSTRDUP(MTYPE_TMP, find.name);
index 2cfb076f003b314f4a2586dcc69762780248c043..e6fdbfd04cb838ffb9a0e541c6294550115194c1 100644 (file)
 
 #include "pbr_map.h"
 
+#define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
+
 struct pbr_nexthop_group_cache {
-       char name[PBR_MAP_NAMELEN];
+       char name[PBR_NHC_NAMELEN];
 
        uint32_t table_id;
 
index ba5c49ad5c7c1ec5ce5bda577fdb089769751099..0f59a50f747f40a300e4a1e9317cdbadc0b5063a 100644 (file)
@@ -269,7 +269,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
        if (pbrms->nhg)
                nh = nexthop_exists(pbrms->nhg, &nhop);
        else {
-               char buf[PBR_MAP_NAMELEN];
+               char buf[PBR_NHC_NAMELEN];
 
                if (no) {
                        vty_out(vty, "No nexthops to delete");
@@ -280,7 +280,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
                pbrms->internal_nhg_name =
                        XSTRDUP(MTYPE_TMP,
                                pbr_nht_nexthop_make_name(pbrms->parent->name,
-                                                         PBR_MAP_NAMELEN - 10,
+                                                         PBR_NHC_NAMELEN,
                                                          pbrms->seqno,
                                                          buf));
                nh = NULL;