summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2014-08-13 07:54:10 +0000
committerWalter Doekes <walter+asterisk@wjd.nu>2014-08-13 07:54:10 +0000
commit52c94d3af43c7330d95efba10ca0090f1ba9a620 (patch)
treeb5b456e586cbbdf67f73ce3ffce2bd92b5392994 /main
parent969982b878596000a45842816f415f2dd8e2a6b1 (diff)
logger: Don't store verbose-magic in the log files.
In r399267, the verbose2magic stuff was edited. This time it results in magic characters in the log files for multiline messages. In trunk (and 13) this was fixed by the "stripping" of those characters from multiline messages (in r414798). This fix is altered to actually strip the characters and not replace them with blanks. Review: https://reviewboard.asterisk.org/r/3901/ Review: https://reviewboard.asterisk.org/r/3902/ ........ Merged revisions 420897 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 420898 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 420899 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420900 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/logger.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/main/logger.c b/main/logger.c
index 13d074c6d..568a6d2e5 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -87,7 +87,7 @@ static int display_callids;
static void unique_callid_cleanup(void *data);
struct ast_callid {
- int call_identifier; /* Numerical value of the call displayed in the logs */
+ int call_identifier; /* Numerical value of the call displayed in the logs */
};
AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, unique_callid_cleanup);
@@ -1179,20 +1179,28 @@ static void ast_log_vsyslog(struct logmsg *msg)
static char *logger_strip_verbose_magic(const char *message, int level)
{
- char *p;
- char *stripped_message = ast_strdup(message);
+ const char *begin, *end;
+ char *stripped_message, *dst;
char magic = -(level + 1);
- if (!stripped_message) {
+ if (!(stripped_message = ast_malloc(strlen(message) + 1))) {
return NULL;
}
+ begin = message;
+ dst = stripped_message;
do {
- p = strchr(stripped_message, (char)magic);
- if (p) {
- *p++ = ' ';
+ end = strchr(begin, magic);
+ if (end) {
+ size_t len = end - begin;
+ memcpy(dst, begin, len);
+ begin = end + 1;
+ dst += len;
+ } else {
+ strcpy(dst, begin); /* safe */
+ break;
}
- } while (p && *p);
+ } while (1);
return stripped_message;
}