init: fix illegal memory access when max message length is reached

Signed-off-by: Yuan-Hsiang Lee <yhlee@ubnt.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Yuan-Hsiang Lee 2013-11-03 00:13:16 +01:00 committed by Denys Vlasenko
parent 18b461925c
commit b21bc80c76

View 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