diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-20 14:12:38 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-20 19:14:33 -0400 |
| commit | 772270f3b6a37a2dd9432541cce436e9b45bb6b9 (patch) | |
| tree | fc7f717a60d056b0300fcf43373a1fff30b94b13 /tools/start-stop-daemon.c | |
| parent | 3f0cc3ffb3ebbc67ebdc285b8093783ad572fa93 (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 'tools/start-stop-daemon.c')
| -rw-r--r-- | tools/start-stop-daemon.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c index 13118a2769..ba40a02f50 100644 --- a/tools/start-stop-daemon.c +++ b/tools/start-stop-daemon.c @@ -607,7 +607,7 @@ static int pid_is_exec(pid_t pid, const struct stat *esb) struct stat sb; char buf[32]; - sprintf(buf, "/proc/%ld/exe", (long)pid); + snprintf(buf, sizeof(buf), "/proc/%ld/exe", (long)pid); if (stat(buf, &sb) != 0) return 0; return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); @@ -619,7 +619,7 @@ static int pid_is_user(pid_t pid, uid_t uid) struct stat sb; char buf[32]; - sprintf(buf, "/proc/%ld", (long)pid); + snprintf(buf, sizeof(buf), "/proc/%ld", (long)pid); if (stat(buf, &sb) != 0) return 0; return (sb.st_uid == uid); @@ -632,7 +632,7 @@ static int pid_is_cmd(pid_t pid, const char *name) FILE *f; int c; - sprintf(buf, "/proc/%ld/stat", (long)pid); + snprintf(buf, sizeof(buf), "/proc/%ld/stat", (long)pid); f = fopen(buf, "r"); if (!f) return 0; |
