]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: debug: Avoid negative array access.
authorJeremy Allison <jra@samba.org>
Mon, 17 Apr 2017 21:09:24 +0000 (14:09 -0700)
committerKarolin Seeger <kseeger@samba.org>
Thu, 20 Apr 2017 10:23:18 +0000 (12:23 +0200)
Report and patch from Hanno Böck <hanno@hboeck.de>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12746

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 600f8787e3b605c9f3e8f724c726e63157ee9efc)

lib/util/debug.c

index 37582dbd1cc5b13377dc06917a66332385bfcf21..8f0c383b15e5e45a6bcaa5abd5c51ecf80375af0 100644 (file)
@@ -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--;
        }