diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-20 20:12:38 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-21 01:14:33 +0200 |
commit | 772270f3b6a37a2dd9432541cce436e9b45bb6b9 (patch) | |
tree | fc7f717a60d056b0300fcf43373a1fff30b94b13 /zebra/zebra_netns_notify.c | |
parent | tools: add more macros to cocci.h (diff) | |
download | frr-772270f3b6a37a2dd9432541cce436e9b45bb6b9.tar.xz frr-772270f3b6a37a2dd9432541cce436e9b45bb6b9.zip |
*: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.
- sprintf's into local scope buffers of known size are replaced with the
equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
buffer followed by strlcat
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_netns_notify.c')
-rw-r--r-- | zebra/zebra_netns_notify.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index d42cf3d60..2e0f9cd3f 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -156,7 +156,7 @@ static int zebra_ns_notify_self_identify(struct stat *netst) char net_path[64]; int netns; - sprintf(net_path, "/proc/self/ns/net"); + snprintf(net_path, sizeof(net_path), "/proc/self/ns/net"); netns = open(net_path, O_RDONLY); if (netns < 0) return -1; @@ -178,7 +178,7 @@ static bool zebra_ns_notify_is_default_netns(const char *name) return false; memset(&st, 0, sizeof(struct stat)); - snprintf(netnspath, 64, "%s/%s", NS_RUN_DIR, name); + snprintf(netnspath, sizeof(netnspath), "%s/%s", NS_RUN_DIR, name); /* compare with local stat */ if (stat(netnspath, &st) == 0 && (st.st_dev == default_netns_stat.st_dev) && |