diff options
author | Simon Ser <contact@emersion.fr> | 2022-02-08 09:52:24 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-02-08 09:20:13 -0500 |
commit | f707f583e17cb5e8323ceb4bfd951ad0465b7d10 (patch) | |
tree | 9de2eaecf63cb4f8e1c0af7ba1c7c9d7a8fd01a4 /sway/tree | |
parent | ac7892371ce1ef7a05619492f0896f525b4dbdc3 (diff) |
Remove all sprintf calls
Replace them with snprintf, which ensures buffer overflows won't
happen.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/root.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 527759ba..09766ce5 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1706,7 +1706,7 @@ static void update_marks_texture(struct sway_container *con, for (int i = 0; i < con->marks->length; ++i) { char *mark = con->marks->items[i]; if (mark[0] != '_') { - sprintf(part, "[%s]", mark); + snprintf(part, len + 1, "[%s]", mark); strcat(buffer, part); } } 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) { FILE *stat = NULL; size_t buf_size = 0; - sprintf(file_name, "/proc/%d/stat", child); + snprintf(file_name, sizeof(file_name), "/proc/%d/stat", child); if ((stat = fopen(file_name, "r"))) { if (getline(&buffer, &buf_size, stat) != -1) { |