From cca76a24b64c966bfb437a6035827c89e4f5fdba Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 14 Mar 2012 10:54:50 +0000 Subject: [PATCH] Fix bogus reads/writes of console log levels in asterisk.c This patch updates the NUMLOGLEVELS define in logger.h to 32, to match the fact that logger.c implements 32 log levels (because of the custom log level stuff). asterisk.c uses this define to size an array of levels per remote console. This array is modified in ast_console_toggle_loglevel(), which is called by the "logger set level" CLI command. While the documentation for the CLI command doesn't make it terribly obvious, you can use this CLI command to toggle a custom log level on a remote console, as well. However, doing so led to an invalid array index in asterisk.c. This array is read from any time a log message is written to a console. So, all custom log level messages resulted in a bogus read if a remote console was connected. ........ Merged revisions 359259 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@359260 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/logger.h | 2 +- main/logger.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index 9363caa748..73e95ca215 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -181,7 +181,7 @@ void ast_console_toggle_loglevel(int fd, int level, int state); #endif #define AST_LOG_DTMF __LOG_DTMF, _A_ -#define NUMLOGLEVELS 7 +#define NUMLOGLEVELS 32 /*! * \brief Get the debug level for a module diff --git a/main/logger.c b/main/logger.c index 5f0416986b..4d88aa6889 100644 --- a/main/logger.c +++ b/main/logger.c @@ -153,7 +153,7 @@ static FILE *qlog; * logchannels list. */ -static char *levels[32] = { +static char *levels[NUMLOGLEVELS] = { "DEBUG", "---EVENT---", /* no longer used */ "NOTICE", @@ -164,7 +164,7 @@ static char *levels[32] = { }; /*! \brief Colors used in the console for logging */ -static const int colors[32] = { +static const int colors[NUMLOGLEVELS] = { COLOR_BRGREEN, COLOR_BRBLUE, /* no longer used */ COLOR_YELLOW, -- 2.47.2