From 5e583af9c55a5bdda6d0f699117a9df163f00b21 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 25 Apr 2026 00:23:54 -0400 Subject: Use strncpy in example code --- src/lib/core/relocation.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/core/relocation.c b/src/lib/core/relocation.c index f7dafe8..16376b3 100644 --- a/src/lib/core/relocation.c +++ b/src/lib/core/relocation.c @@ -8,8 +8,9 @@ * Replace all occurrences of `target` with `replacement` in `original` * * ~~~{.c} - * char *str = calloc(100, sizeof(char)); - * strcpy(str, "This are a test."); + * size_t str_maxlen = 100; + * char *str = calloc(str_maxlen, sizeof(char)); + * strncpy(str, "This are a test.", str_maxlen - 1); * if (replace_text(str, "are", "is")) { * fprintf(stderr, "string replacement failed\n"); * exit(1); -- cgit