summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2020-04-23 20:27:26 +0200
committerGitHub <noreply@github.com>2020-04-23 20:27:26 +0200
commitc334a16ef105b7b187943db177ed7623b01e79ba (patch)
tree79aa1a7def3eadc711549e9b0e81a773ca5fa569 /pimd
parentMerge pull request #6184 from kssoman/route (diff)
parentpimd, lib: suppress compiler warnings on snprintf (diff)
downloadfrr-c334a16ef105b7b187943db177ed7623b01e79ba.tar.xz
frr-c334a16ef105b7b187943db177ed7623b01e79ba.zip
Merge pull request #6262 from qlyoung/remove-sprintf
Diffstat (limited to 'pimd')
-rw-r--r--pimd/mtracebis.c4
-rw-r--r--pimd/pim_cmd.c8
-rw-r--r--pimd/pim_igmp.c2
-rw-r--r--pimd/pim_igmpv3.c3
-rw-r--r--pimd/pim_instance.c2
-rw-r--r--pimd/pim_msdp.c6
-rw-r--r--pimd/pim_nht.c2
-rw-r--r--pimd/pim_rp.c6
-rw-r--r--pimd/pim_sock.c8
-rw-r--r--pimd/pim_upstream.c3
-rw-r--r--pimd/pim_vty.c4
11 files changed, 27 insertions, 21 deletions
diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c
index 2f10abcce..1b812de92 100644
--- a/pimd/mtracebis.c
+++ b/pimd/mtracebis.c
@@ -108,7 +108,7 @@ static const char *rtg_proto_str(enum mtrace_rtg_proto proto)
case MTRACE_RTG_PROTO_PIM_ASSERT:
return "PIM assert";
default:
- sprintf(buf, "unknown protocol (%d)", proto);
+ snprintf(buf, sizeof(buf), "unknown protocol (%d)", proto);
return buf;
}
}
@@ -161,7 +161,7 @@ static const char *fwd_code_str(enum mtrace_fwd_code code)
case MTRACE_FWD_CODE_ADMIN_PROHIB:
return "admin. prohib.";
default:
- sprintf(buf, "unknown fwd. code (%d)", code);
+ snprintf(buf, sizeof(buf), "unknown fwd. code (%d)", code);
return buf;
}
}
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index f6af98598..fe9b5e1be 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -2510,10 +2510,12 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
pim_upstream_state2brief_str(up->join_state, state_str, sizeof(state_str));
if (up->reg_state != PIM_REG_NOINFO) {
char tmp_str[PIM_REG_STATE_STR_LEN];
+ char tmp[sizeof(state_str) + 1];
- sprintf(state_str + strlen(state_str), ",%s",
- pim_reg_state2brief_str(up->reg_state, tmp_str,
- sizeof(tmp_str)));
+ snprintf(tmp, sizeof(tmp), ",%s",
+ pim_reg_state2brief_str(up->reg_state, tmp_str,
+ sizeof(tmp_str)));
+ strlcat(state_str, tmp, sizeof(state_str));
}
if (uj) {
diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c
index 461c2698d..851b00b2a 100644
--- a/pimd/pim_igmp.c
+++ b/pimd/pim_igmp.c
@@ -913,7 +913,7 @@ static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,
igmp->igmp_group_list = list_new();
igmp->igmp_group_list->del = (void (*)(void *))igmp_group_free;
- snprintf(hash_name, 64, "IGMP %s hash", ifp->name);
+ snprintf(hash_name, sizeof(hash_name), "IGMP %s hash", ifp->name);
igmp->igmp_group_hash = hash_create(igmp_group_hash_key,
igmp_group_hash_equal, hash_name);
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index ffd872ce0..8eaca7582 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -1945,7 +1945,8 @@ int igmp_v3_recv_report(struct igmp_sock *igmp, struct in_addr from,
if (!inet_ntop(AF_INET, src, src_str,
sizeof(src_str)))
- sprintf(src_str, "<source?>");
+ snprintf(src_str, sizeof(src_str),
+ "<source?>");
zlog_debug(
" Recv IGMP report v3 from %s on %s: record=%d group=%s source=%s",
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index b4c2dd28c..b7e49078e 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -99,7 +99,7 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
pim_msdp_init(pim, router->master);
pim_vxlan_init(pim);
- snprintf(hash_name, 64, "PIM %s RPF Hash", vrf->name);
+ snprintf(hash_name, sizeof(hash_name), "PIM %s RPF Hash", vrf->name);
pim->rpf_hash = hash_create_size(256, pim_rpf_hash_key, pim_rpf_equal,
hash_name);
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 52c989e64..b42092a46 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -1574,14 +1574,16 @@ void pim_msdp_init(struct pim_instance *pim, struct thread_master *master)
pim->msdp.master = master;
char hash_name[64];
- snprintf(hash_name, 64, "PIM %s MSDP Peer Hash", pim->vrf->name);
+ snprintf(hash_name, sizeof(hash_name), "PIM %s MSDP Peer Hash",
+ pim->vrf->name);
pim->msdp.peer_hash = hash_create(pim_msdp_peer_hash_key_make,
pim_msdp_peer_hash_eq, hash_name);
pim->msdp.peer_list = list_new();
pim->msdp.peer_list->del = (void (*)(void *))pim_msdp_peer_free;
pim->msdp.peer_list->cmp = (int (*)(void *, void *))pim_msdp_peer_comp;
- snprintf(hash_name, 64, "PIM %s MSDP SA Hash", pim->vrf->name);
+ snprintf(hash_name, sizeof(hash_name), "PIM %s MSDP SA Hash",
+ pim->vrf->name);
pim->msdp.sa_hash = hash_create(pim_msdp_sa_hash_key_make,
pim_msdp_sa_hash_eq, hash_name);
pim->msdp.sa_list = list_new();
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index 68d43c055..a888d68f0 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -103,7 +103,7 @@ static struct pim_nexthop_cache *pim_nexthop_cache_add(struct pim_instance *pim,
pnc->rp_list = list_new();
pnc->rp_list->cmp = pim_rp_list_cmp;
- snprintf(hash_name, 64, "PNC %s(%s) Upstream Hash",
+ snprintf(hash_name, sizeof(hash_name), "PNC %s(%s) Upstream Hash",
prefix2str(&pnc->rpf.rpf_addr, buf1, 64), pim->vrf->name);
pnc->upstream_hash = hash_create_size(8192, pim_upstream_hash_key,
pim_upstream_equal, hash_name);
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index d9e93f95f..1611eac95 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -728,7 +728,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
char rp_str[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &rp_addr, rp_str, sizeof(rp_str)))
- sprintf(rp_str, "<rp?>");
+ snprintf(rp_str, sizeof(rp_str), "<rp?>");
prefix2str(&group, grp_str, sizeof(grp_str));
if (plist)
@@ -763,7 +763,9 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
if (!inet_ntop(AF_INET, bsrp, bsrp_str,
sizeof(bsrp_str)))
- sprintf(bsrp_str, "<bsrp?>");
+ snprintf(bsrp_str,
+ sizeof(bsrp_str),
+ "<bsrp?>");
zlog_debug(
"%s: BSM RP %s found for the group %s",
diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c
index f0a71c96c..504519c8a 100644
--- a/pimd/pim_sock.c
+++ b/pimd/pim_sock.c
@@ -288,10 +288,10 @@ int pim_socket_join(int fd, struct in_addr group, struct in_addr ifaddr,
char group_str[INET_ADDRSTRLEN];
char ifaddr_str[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &group, group_str, sizeof(group_str)))
- sprintf(group_str, "<group?>");
+ snprintf(group_str, sizeof(group_str), "<group?>");
if (!inet_ntop(AF_INET, &ifaddr, ifaddr_str,
sizeof(ifaddr_str)))
- sprintf(ifaddr_str, "<ifaddr?>");
+ snprintf(ifaddr_str, sizeof(ifaddr_str), "<ifaddr?>");
flog_err(
EC_LIB_SOCKET,
@@ -304,10 +304,10 @@ int pim_socket_join(int fd, struct in_addr group, struct in_addr ifaddr,
char group_str[INET_ADDRSTRLEN];
char ifaddr_str[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &group, group_str, sizeof(group_str)))
- sprintf(group_str, "<group?>");
+ snprintf(group_str, sizeof(group_str), "<group?>");
if (!inet_ntop(AF_INET, &ifaddr, ifaddr_str,
sizeof(ifaddr_str)))
- sprintf(ifaddr_str, "<ifaddr?>");
+ snprintf(ifaddr_str, sizeof(ifaddr_str), "<ifaddr?>");
zlog_debug(
"Socket fd=%d joined group %s on interface address %s",
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index 1e78f4135..cf5ea2fa5 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -2165,8 +2165,7 @@ void pim_upstream_init(struct pim_instance *pim)
{
char name[64];
- snprintf(name, 64, "PIM %s Timer Wheel",
- pim->vrf->name);
+ snprintf(name, sizeof(name), "PIM %s Timer Wheel", pim->vrf->name);
pim->upstream_sg_wheel =
wheel_init(router->master, 31000, 100, pim_upstream_hash_key,
pim_upstream_sg_running, name);
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index fee8d6ed1..1f2ca11db 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -172,9 +172,9 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
char spaces[10];
if (pim->vrf_id == VRF_DEFAULT)
- sprintf(spaces, "%s", "");
+ snprintf(spaces, sizeof(spaces), "%s", "");
else
- sprintf(spaces, "%s", " ");
+ snprintf(spaces, sizeof(spaces), "%s", " ");
writes += pim_msdp_config_write(pim, vty, spaces);