summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2019-05-06 23:05:06 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-05-29 20:02:57 +0200
commit552d6491f08de30b97af876ab923aea10f1b0a1c (patch)
tree3ada7488d4af982803cb350f58f1b15aa5335948 /bgpd
parentbgpd: fix rfapi false compiler warning (diff)
downloadfrr-552d6491f08de30b97af876ab923aea10f1b0a1c.tar.xz
frr-552d6491f08de30b97af876ab923aea10f1b0a1c.zip
bgpd: remove strcpy, strcat
Replace with strlcpy, strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_community.c47
-rw-r--r--bgpd/bgp_packet.c23
-rw-r--r--bgpd/bgp_routemap.c8
3 files changed, 34 insertions, 44 deletions
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 82762072d..c9d36749e 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -308,12 +308,11 @@ static void set_community_string(struct community *com, bool make_json)
if (first)
first = 0;
else
- *pnt++ = ' ';
+ strlcat(str, " ", len);
switch (comval) {
case COMMUNITY_INTERNET:
- strcpy(pnt, "internet");
- pnt += strlen("internet");
+ strlcat(str, "internet", len);
if (make_json) {
json_string =
json_object_new_string("internet");
@@ -322,8 +321,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_GSHUT:
- strcpy(pnt, "graceful-shutdown");
- pnt += strlen("graceful-shutdown");
+ strlcat(pnt, "graceful-shutdown", len);
if (make_json) {
json_string = json_object_new_string(
"gracefulShutdown");
@@ -332,8 +330,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ACCEPT_OWN:
- strcpy(pnt, "accept-own");
- pnt += strlen("accept-own");
+ strlcat(pnt, "accept-own", len);
if (make_json) {
json_string = json_object_new_string(
"acceptown");
@@ -342,8 +339,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4:
- strcpy(pnt, "route-filter-translated-v4");
- pnt += strlen("route-filter-translated-v4");
+ strlcat(pnt, "route-filter-translated-v4", len);
if (make_json) {
json_string = json_object_new_string(
"routeFilterTranslatedV4");
@@ -352,8 +348,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ROUTE_FILTER_v4:
- strcpy(pnt, "route-filter-v4");
- pnt += strlen("route-filter-v4");
+ strlcat(pnt, "route-filter-v4", len);
if (make_json) {
json_string = json_object_new_string(
"routeFilterV4");
@@ -362,8 +357,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6:
- strcpy(pnt, "route-filter-translated-v6");
- pnt += strlen("route-filter-translated-v6");
+ strlcat(pnt, "route-filter-translated-v6", len);
if (make_json) {
json_string = json_object_new_string(
"routeFilterTranslatedV6");
@@ -372,8 +366,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ROUTE_FILTER_v6:
- strcpy(pnt, "route-filter-v6");
- pnt += strlen("route-filter-v6");
+ strlcat(pnt, "route-filter-v6", len);
if (make_json) {
json_string = json_object_new_string(
"routeFilterV6");
@@ -382,8 +375,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_LLGR_STALE:
- strcpy(pnt, "llgr-stale");
- pnt += strlen("llgr-stale");
+ strlcat(pnt, "llgr-stale", len);
if (make_json) {
json_string = json_object_new_string(
"llgrStale");
@@ -392,8 +384,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_NO_LLGR:
- strcpy(pnt, "no-llgr");
- pnt += strlen("no-llgr");
+ strlcat(pnt, "no-llgr", len);
if (make_json) {
json_string = json_object_new_string(
"noLlgr");
@@ -402,8 +393,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_ACCEPT_OWN_NEXTHOP:
- strcpy(pnt, "accept-own-nexthop");
- pnt += strlen("accept-own-nexthop");
+ strlcat(pnt, "accept-own-nexthop", len);
if (make_json) {
json_string = json_object_new_string(
"acceptownnexthop");
@@ -412,8 +402,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_BLACKHOLE:
- strcpy(pnt, "blackhole");
- pnt += strlen("blackhole");
+ strlcat(pnt, "blackhole", len);
if (make_json) {
json_string = json_object_new_string(
"blackhole");
@@ -422,8 +411,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_NO_EXPORT:
- strcpy(pnt, "no-export");
- pnt += strlen("no-export");
+ strlcat(pnt, "no-export", len);
if (make_json) {
json_string =
json_object_new_string("noExport");
@@ -432,8 +420,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_NO_ADVERTISE:
- strcpy(pnt, "no-advertise");
- pnt += strlen("no-advertise");
+ strlcat(pnt, "no-advertise", len);
if (make_json) {
json_string =
json_object_new_string("noAdvertise");
@@ -442,8 +429,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_LOCAL_AS:
- strcpy(pnt, "local-AS");
- pnt += strlen("local-AS");
+ strlcat(pnt, "local-AS", len);
if (make_json) {
json_string = json_object_new_string("localAs");
json_object_array_add(json_community_list,
@@ -451,8 +437,7 @@ static void set_community_string(struct community *com, bool make_json)
}
break;
case COMMUNITY_NO_PEER:
- strcpy(pnt, "no-peer");
- pnt += strlen("no-peer");
+ strlcat(pnt, "no-peer", len);
if (make_json) {
json_string = json_object_new_string("noPeer");
json_object_array_add(json_community_list,
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index c37e125f5..de7df1d47 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -709,12 +709,15 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
for (i = 0; i < bgp_notify.length; i++)
if (first) {
- sprintf(c, " %02x", data[i]);
- strcat(bgp_notify.data, c);
+ snprintf(c, sizeof(c), " %02x",
+ data[i]);
+ strlcat(bgp_notify.data, c,
+ bgp_notify.length);
} else {
first = 1;
- sprintf(c, "%02x", data[i]);
- strcpy(bgp_notify.data, c);
+ snprintf(c, sizeof(c), "%02x", data[i]);
+ strlcpy(bgp_notify.data, c,
+ bgp_notify.length);
}
}
bgp_notify_print(peer, &bgp_notify, "sending");
@@ -1700,14 +1703,16 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
for (i = 0; i < bgp_notify.length; i++)
if (first) {
- sprintf(c, " %02x",
+ snprintf(c, sizeof(c), " %02x",
stream_getc(peer->curr));
- strcat(bgp_notify.data, c);
+ strlcat(bgp_notify.data, c,
+ bgp_notify.length);
} else {
first = 1;
- sprintf(c, "%02x",
- stream_getc(peer->curr));
- strcpy(bgp_notify.data, c);
+ snprintf(c, sizeof(c), "%02x",
+ stream_getc(peer->curr));
+ strlcpy(bgp_notify.data, c,
+ bgp_notify.length);
}
bgp_notify.raw_data = (uint8_t *)peer->notify.data;
}
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index b0ae9d78d..c8386e6cb 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -4222,10 +4222,10 @@ DEFUN (set_community,
str = community_str(com, false);
if (additive) {
- argstr = XCALLOC(MTYPE_TMP,
- strlen(str) + strlen(" additive") + 1);
- strcpy(argstr, str);
- strcpy(argstr + strlen(str), " additive");
+ size_t argstr_sz = strlen(str) + strlen(" additive") + 1;
+ argstr = XCALLOC(MTYPE_TMP, argstr_sz);
+ strlcpy(argstr, str, argstr_sz);
+ strlcat(argstr, " additive", argstr_sz);
ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
"community", argstr);
XFREE(MTYPE_TMP, argstr);