From 959ceb6aae807029399e4be311db3c954a70bf18 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 17 Apr 2017 14:09:24 -0700 Subject: [PATCH] lib: debug: Avoid negative array access. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Report and patch from Hanno Böck . BUG: https://bugzilla.samba.org/show_bug.cgi?id=12746 Signed-off-by: Jeremy Allison --- lib/util/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/debug.c b/lib/util/debug.c index f48daf69553..5abca41d534 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -488,7 +488,7 @@ static void debug_backends_log(const char *msg, int msg_level) * a buffer without the newline character. */ len = MIN(strlen(msg), FORMAT_BUFR_SIZE - 1); - if (msg[len - 1] == '\n') { + if ((len > 0) && (msg[len - 1] == '\n')) { len--; } -- 2.12.2.762.g0e3151a226-goog