init: fix illegal memory access when max message length is reached
authorYuan-Hsiang Lee <yhlee@ubnt.com>
Sat, 2 Nov 2013 23:13:16 +0000 (00:13 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 2 Nov 2013 23:13:16 +0000 (00:13 +0100)
Signed-off-by: Yuan-Hsiang Lee <yhlee@ubnt.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
init/init.c

index cc6a2b5be5e7c35a08d8948fc479c3990c7ce618..2dcdfd471650695f4503aa8333227a98665e6ceb 100644 (file)
@@ -222,8 +222,8 @@ static void message(int where, const char *fmt, ...)
        msg[0] = '\r';
        va_start(arguments, fmt);
        l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
-       if (l > sizeof(msg) - 1)
-               l = sizeof(msg) - 1;
+       if (l > sizeof(msg) - 2)
+               l = sizeof(msg) - 2;
        va_end(arguments);
 
 #if ENABLE_FEATURE_INIT_SYSLOG