1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +03:00

lib: debug: Avoid negative array access.

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>
This commit is contained in:
Jeremy Allison
2017-04-17 14:09:24 -07:00
committed by Andreas Schneider
parent bf8f7a36bf
commit 600f8787e3

View File

@ -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--;
}