summaryrefslogtreecommitdiff
path: root/zebra/zebra_fpm.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-04-20 14:12:38 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-04-20 19:14:33 -0400
commit772270f3b6a37a2dd9432541cce436e9b45bb6b9 (patch)
treefc7f717a60d056b0300fcf43373a1fff30b94b13 /zebra/zebra_fpm.c
parent3f0cc3ffb3ebbc67ebdc285b8093783ad572fa93 (diff)
*: 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_fpm.c')
-rw-r--r--zebra/zebra_fpm.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index 41d73f3c97..8f97c8cf47 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -760,8 +760,9 @@ static int zfpm_read_cb(struct thread *thread)
if (nbyte == -1) {
char buffer[1024];
- sprintf(buffer, "closed socket in read(%d): %s",
- errno, safe_strerror(errno));
+ snprintf(buffer, sizeof(buffer),
+ "closed socket in read(%d): %s", errno,
+ safe_strerror(errno));
zfpm_connection_down(buffer);
} else
zfpm_connection_down("closed socket in read");
@@ -797,8 +798,9 @@ static int zfpm_read_cb(struct thread *thread)
if (nbyte == -1) {
char buffer[1024];
- sprintf(buffer, "failed to read message(%d) %s",
- errno, safe_strerror(errno));
+ snprintf(buffer, sizeof(buffer),
+ "failed to read message(%d) %s", errno,
+ safe_strerror(errno));
zfpm_connection_down(buffer);
} else
zfpm_connection_down("failed to read message");