aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/root.c
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2022-02-08 09:52:24 +0100
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2022-02-08 09:20:13 -0500
commitf707f583e17cb5e8323ceb4bfd951ad0465b7d10 (patch)
tree9de2eaecf63cb4f8e1c0af7ba1c7c9d7a8fd01a4 /sway/tree/root.c
parentFix snprintf compiler warning (diff)
downloadsway-f707f583e17cb5e8323ceb4bfd951ad0465b7d10.tar.gz
sway-f707f583e17cb5e8323ceb4bfd951ad0465b7d10.tar.zst
sway-f707f583e17cb5e8323ceb4bfd951ad0465b7d10.zip
Remove all sprintf calls
Replace them with snprintf, which ensures buffer overflows won't happen.
Diffstat (limited to 'sway/tree/root.c')
-rw-r--r--sway/tree/root.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 73f3993c..8508e9eb 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -209,7 +209,7 @@ static pid_t get_parent_pid(pid_t child) {
209 FILE *stat = NULL; 209 FILE *stat = NULL;
210 size_t buf_size = 0; 210 size_t buf_size = 0;
211 211
212 sprintf(file_name, "/proc/%d/stat", child); 212 snprintf(file_name, sizeof(file_name), "/proc/%d/stat", child);
213 213
214 if ((stat = fopen(file_name, "r"))) { 214 if ((stat = fopen(file_name, "r"))) {
215 if (getline(&buffer, &buf_size, stat) != -1) { 215 if (getline(&buffer, &buf_size, stat) != -1) {