summaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2022-03-24 18:14:50 +0100
committerPhil Sutter <phil@nwl.cc>2022-03-28 12:19:44 +0200
commit0e05989f3247e9aef0d96aafc144b2d853732891 (patch)
tree725c9078d4752c68dc796e82d89954fa1f19927a /src/process.c
parent549f90d8a7847f201aa604a0cf7c24b73d4b5a56 (diff)
Fix potential buffer overrun in snprintf() calls
When consecutively printing into the same buffer at increasing offset, reduce buffer size passed to snprintf() to not defeat its size checking. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/process.c b/src/process.c
index 3ddad5f..08598ee 100644
--- a/src/process.c
+++ b/src/process.c
@@ -84,7 +84,7 @@ void fork_process_dump(int fd)
int size = 0;
list_for_each_entry(this, &process_list, head) {
- size += snprintf(buf+size, sizeof(buf),
+ size += snprintf(buf + size, sizeof(buf) - size,
"PID=%u type=%s\n",
this->pid,
this->type < CTD_PROC_MAX ?