aboutsummaryrefslogtreecommitdiff
path: root/src/template.c
diff options
context:
space:
mode:
authorfrosty <frostinator33@airmail.cc>2026-10-27 21:53:15 -0400
committerfrosty <frostinator33@airmail.cc>2026-10-27 21:54:38 -0400
commitb7494ffb33a74aa7b81e503891aef2ac6c1d6a56 (patch)
tree05adada790ee2e786e03af2b25bc4d1d0fae51ef /src/template.c
parent10be7f581fb828e74f064ea7ad4fb0534ee8540a (diff)
refactor: replace potentially unsafe string functions
Diffstat (limited to 'src/template.c')
-rw-r--r--src/template.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/template.c b/src/template.c
index d2dea64..8f0f22b 100644
--- a/src/template.c
+++ b/src/template.c
@@ -402,7 +402,7 @@ static char *html_escape(const char *input) {
}
output = new_output;
}
- strcat(output, replacement);
+ strncat(output, replacement, estimated_len - current_output_len - 1);
current_output_len += repl_len;
} else {
@@ -456,7 +456,7 @@ static void append_to_buffer(char **buffer, size_t *current_len,
*buffer = new_buffer;
}
- strcat(*buffer, str_to_add);
+ strncat(*buffer, str_to_add, *max_len - *current_len - 1);
*current_len += add_len;
}
@@ -840,7 +840,7 @@ static char *render_template_segment(const char *template_segment,
if (strncmp(trimmed_tag_content, "for ", 4) == 0) {
char loop_var[MAX_KEY_LEN];
char list_var[MAX_KEY_LEN];
- if (sscanf(trimmed_tag_content, "for %s in %s", loop_var, list_var) ==
+ if (sscanf(trimmed_tag_content, "for %63s in %63s", loop_var, list_var) ==
2) {
ContextVar *list_ctx_var = find_context_var(ctx, list_var);