]> git.proxmox.com Git - mirror_frr.git/commitdiff
pbrd: fix multiple unsafe string copies
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 17 Apr 2018 22:20:53 +0000 (18:20 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 18 Apr 2018 16:16:19 +0000 (12:16 -0400)
Coverity #1467828
Coverity #1467827
Coverity #1467826
Coverity #1467825
Coverity #1467824
Coverity #1467823
Coverity #1467822

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
pbrd/pbr_map.c
pbrd/pbr_nht.c

index ea79320a712501a12bbd9adc61d3667b383366f6..10940e1548608cddcbade3d59172473a10c8e1b4 100644 (file)
@@ -268,7 +268,7 @@ struct pbr_map_sequence *pbrms_get(const char *name, uint32_t seqno)
        pbrm = pbrm_find(name);
        if (!pbrm) {
                pbrm = XCALLOC(MTYPE_PBR_MAP, sizeof(*pbrm));
-               strcpy(pbrm->name, name);
+               snprintf(pbrm->name, sizeof(pbrm->name), "%s", name);
 
                pbrm->seqnumbers = list_new();
                pbrm->seqnumbers->cmp =
index 4a420c3e8481c85d227b965ccc5db9d362c2aad5..19bc1804de0b421889be36d5a6888631155dc5c8 100644 (file)
@@ -440,7 +440,7 @@ void pbr_nht_change_group(const char *name)
                return;
 
        memset(&find, 0, sizeof(find));
-       strcpy(find.name, name);
+       snprintf(find.name, sizeof(find.name), "%s", name);
        pnhgc = hash_lookup(pbr_nhg_hash, &find);
 
        if (!pnhgc) {
@@ -515,7 +515,7 @@ void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms)
        pbrms->reason |= PBR_MAP_INVALID_NO_NEXTHOPS;
 
        memset(&find, 0, sizeof(find));
-       strcpy(&find.name[0], pbrms->internal_nhg_name);
+       snprintf(find.name, sizeof(find.name), "%s", pbrms->internal_nhg_name);
        pnhgc = hash_lookup(pbr_nhg_hash, &find);
 
        nh = pbrms->nhg->nexthop;
@@ -550,7 +550,7 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name)
                return NULL;
        }
 
-       strcpy(lookup.name, name);
+       snprintf(lookup.name, sizeof(lookup.name), "%s", name);
        pnhgc = hash_get(pbr_nhg_hash, &lookup, pbr_nhgc_alloc);
        DEBUGD(&pbr_dbg_nht, "%s: Retrieved NHGC @ %p", __PRETTY_FUNCTION__,
               pnhgc);
@@ -609,7 +609,7 @@ bool pbr_nht_nexthop_group_valid(const char *name)
 
        DEBUGD(&pbr_dbg_nht, "%s: %s", __PRETTY_FUNCTION__, name);
 
-       strcpy(lookup.name, name);
+       snprintf(lookup.name, sizeof(lookup.name), "%s", name);
        pnhgc = hash_get(pbr_nhg_hash, &lookup, NULL);
        if (!pnhgc)
                return false;
@@ -764,7 +764,7 @@ uint32_t pbr_nht_get_table(const char *name)
        struct pbr_nexthop_group_cache *pnhgc;
 
        memset(&find, 0, sizeof(find));
-       strcpy(find.name, name);
+       snprintf(find.name, sizeof(find.name), "%s", name);
        pnhgc = hash_lookup(pbr_nhg_hash, &find);
 
        if (!pnhgc) {
@@ -783,7 +783,7 @@ bool pbr_nht_get_installed(const char *name)
        struct pbr_nexthop_group_cache *pnhgc;
 
        memset(&find, 0, sizeof(find));
-       strcpy(find.name, name);
+       snprintf(find.name, sizeof(find.name), "%s", name);
 
        pnhgc = hash_lookup(pbr_nhg_hash, &find);