base: print last character of unterminated strings

The last character should only be skipped if a `\0` or `\n` is found. If
the string ends without such a character or the maximum line length is
hit, we do not skip the last character.

Fixes genodelabs/genode#4985
This commit is contained in:
Johannes Schlatow 2023-08-22 10:48:38 +02:00 committed by Christian Helmuth
parent e78a84196d
commit 0622446f09

View File

@ -67,17 +67,16 @@ void Genode::print_lines(char const *string, size_t len, FUNC const &func)
string += num_indent_chars;
size_t line_len = 0;
size_t skip_char = 1;
size_t skip_char = 0;
for (; line_len < len; line_len++) {
if (string[line_len] == '\0' || string[line_len] == '\n') {
line_len++;
skip_char = 1;
break;
}
if (line_len == MAX_LINE_LEN) {
skip_char = 0;
if (line_len == MAX_LINE_LEN)
break;
}
}
if (!line_len)