From 5d516f87bee122c09e194dbb510b972481dd733e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 7 Jul 2014 08:27:44 +1000 Subject: [PATCH] os: prevent negative array index access If an empty string is provided to LogMessageVerbSigSafe, the length of the printed string is 0. Read-only access only and the only effect it had was adding a linebreak or not. Signed-off-by: Peter Hutterer --- os/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/log.c b/os/log.c index a368569..2a721b9 100644 --- a/os/log.c +++ b/os/log.c @@ -697,7 +697,7 @@ LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list a if (sizeof(buf) - len == 1) buf[len - 1] = '\n'; - newline = (buf[len - 1] == '\n'); + newline = (len > 0 && buf[len - 1] == '\n'); LogSWrite(verb, buf, len, newline); } -- 1.9.3