From d4687bb2efa0b6c194a02ea99bf25bb95c59ef33 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 Reviewed-by: Martin Schwenke Reviewed-by: Andreas Schneider (cherry picked from commit 600f8787e3b605c9f3e8f724c726e63157ee9efc) --- 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 37582dbd1cc..8f0c383b15e 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -397,7 +397,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.816.g2cccc81164-goog