summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-06-03 13:29:16 +0000
committerRussell Bryant <russell@russellbryant.com>2008-06-03 13:29:16 +0000
commit8b0ea3a76dd83e82ff5bea63128c198b4c1106ff (patch)
tree9cac6aa77309f6b75628cb11610095adfaa97c19 /main/logger.c
parentd6240ac21eb798f1c7cee4e72fbb1b5f730d4ffa (diff)
Do a deep copy of file and function strings to avoid a potential crash when
modules are unloaded. (closes issue #12780) Reported by: ys Patches: logger.diff uploaded by ys (license 281) -- modified by me for coding guidelines git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@119892 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/main/logger.c b/main/logger.c
index 94cbac208..23704473e 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -133,9 +133,9 @@ struct logmsg {
enum logmsgtypes type;
char date[256];
int level;
- const char *file;
+ char file[80];
int line;
- const char *function;
+ char function[80];
AST_LIST_ENTRY(logmsg) list;
char str[0];
};
@@ -1135,7 +1135,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
/* Create a new logging message */
if (!(logmsg = ast_calloc(1, sizeof(*logmsg) + res + 1)))
return;
-
+
/* Copy string over */
strcpy(logmsg->str, buf->str);
@@ -1148,9 +1148,9 @@ void ast_log(int level, const char *file, int line, const char *function, const
/* Copy over data */
logmsg->level = level;
- logmsg->file = file;
logmsg->line = line;
- logmsg->function = function;
+ ast_copy_string(logmsg->file, file, sizeof(logmsg->file));
+ ast_copy_string(logmsg->function, function, sizeof(logmsg->function));
/* If the logger thread is active, append it to the tail end of the list - otherwise skip that step */
if (logthread != AST_PTHREADT_NULL) {