From c9d485472e9b6e8e9bda7b99a1b58b123b29e540 Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Thu, 23 Nov 2023 10:51:53 +0100 Subject: [PATCH] =?UTF-8?q?separator=20:=20suppression=20d'un=20comporteme?= =?UTF-8?q?nt=20ind=C3=A9fini=20avec=20strlen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/separator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/separator.c b/src/separator.c index 575011c..bffa2b3 100644 --- a/src/separator.c +++ b/src/separator.c @@ -12,6 +12,9 @@ static char *separation_character_line(const char *separation_character, const u const size_t character_length = strlen(separation_character); char *line = malloc(line_length * sizeof(char)); + // Avoiding undefined behaviour with strlen if no null byte is + // present at the end of line + *line = 0; while (strlen(line) + character_length <= line_length) { strncat(line, separation_character, character_length);