From 4e5819d16959078be41710349d59a022fcafd038 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 20 Apr 2014 18:23:07 +0400 Subject: [PATCH] (str_8bit_fit_to_term): fix out-of-bound write. Signed-off-by: Andrew Borodin --- lib/strutil/strutil8bit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/strutil/strutil8bit.c b/lib/strutil/strutil8bit.c index 6ff4f8aaf..29bc56fc9 100644 --- a/lib/strutil/strutil8bit.c +++ b/lib/strutil/strutil8bit.c @@ -338,6 +338,8 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode) } finally: + if (actual >= result + sizeof (result)) + actual = result + sizeof (result) - 1; actual[0] = '\0'; return result; }