From 09f504dc89205fa1163789cceae2704286e65950 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 10 Dec 2021 21:36:42 -0600 Subject: [PATCH] Bugfix: Raw formatted print sometimes prints trailing NULL. A logic flaw is resulting in the last NULL after the max length is reached to be printed. When the strnlen() calculates the length and the calculated length is the requested max length, the subsequent line attempts to print any NULLs. This is normally fine, except that it needs to check to make sure that "i" is less than the requested max length. --- level_0/f_print/c/private-print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/level_0/f_print/c/private-print.c b/level_0/f_print/c/private-print.c index 8251c4f..5ac1b10 100644 --- a/level_0/f_print/c/private-print.c +++ b/level_0/f_print/c/private-print.c @@ -522,7 +522,7 @@ extern "C" { } // Print all NULL characters. - if (!string[i]) { + if (i < length && !string[i]) { start = i; do { -- 1.8.3.1