[Home]

Summary:ASTERISK-12134: [patch] logger.c may random crash asterisk on module unload for some OS
Reporter:Yuri (ys)Labels:
Date Opened:2008-06-03 08:13:35Date Closed:2008-06-03 08:24:08
Priority:MinorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_config
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) logger.diff
Description:
logmsg structure contain file and function pointer, which hold pointer to file name and function name accordingly.
But memory, which these pointer refer, may be already freed and inaccessible by logger thread - logger_thread(), if the module is already unloaded at moment that logger thread call function to print this log entry.

This mainly affected OS that use constructor/destructor.



****** ADDITIONAL INFORMATION ******

*CLI> module unload chan_agent.so
 == Unregistered channel type 'Agent'
 == Unregistered custom function AGENT
 == Unregistered application 'AgentLogin'
 == Unregistered application 'AgentMonitorOutgoing'
 == Manager unregistered action Agents
 == Manager unregistered action AgentLogoff
Segmentation fault (core dumped)
Comments:By: Russell Bryant (russell) 2008-06-03 08:20:21

1) bzero() is not needed since the memory is allocated using calloc()

2) Please use ast_copy_string() instead of strncpy()

By: Digium Subversion (svnbot) 2008-06-03 08:22:41

Repository: asterisk
Revision: 119892

U   trunk/main/logger.c

------------------------------------------------------------------------
r119892 | russell | 2008-06-03 08:22:38 -0500 (Tue, 03 Jun 2008) | 9 lines

Do a deep copy of file and function strings to avoid a potential crash when
modules are unloaded.

(closes issue ASTERISK-12134)
Reported by: ys
Patches:
     logger.diff uploaded by ys (license 281)
 -- modified by me for coding guidelines

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=119892

By: Digium Subversion (svnbot) 2008-06-03 08:24:08

Repository: asterisk
Revision: 119893

_U  branches/1.6.0/
U   branches/1.6.0/main/logger.c

------------------------------------------------------------------------
r119893 | russell | 2008-06-03 08:24:08 -0500 (Tue, 03 Jun 2008) | 17 lines

Merged revisions 119892 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
r119892 | russell | 2008-06-03 08:29:16 -0500 (Tue, 03 Jun 2008) | 9 lines

Do a deep copy of file and function strings to avoid a potential crash when
modules are unloaded.

(closes issue ASTERISK-12134)
Reported by: ys
Patches:
     logger.diff uploaded by ys (license 281)
 -- modified by me for coding guidelines

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=119893