[asterisk-dev] [svn-commits] rizzo: trunk r93603 - in /trunk: channels/ include/asterisk/ main/ res/ utils/

Maxim Sobolev sobomax at sippysoft.com
Wed Dec 19 17:03:18 CST 2007


Luigi Rizzo wrote:
> On Wed, Dec 19, 2007 at 10:36:34PM +0100, Michiel van Baak wrote:
>> On 14:26, Wed 19 Dec 07, Jason Parker wrote:
>>> SVN commits to the Digium repositories wrote:
>>>> Author: rizzo
>>>> Date: Tue Dec 18 04:24:58 2007
>>>> New Revision: 93603
>>>>
>>>> URL: http://svn.digium.com/view/asterisk?view=rev&rev=93603
>>>> Log:
>>>> make configuration variable const so they are not accidentally
>>>> modified.
>>>> This requires casting the strings in asterisk.c when writing to
>>>> them, so we do it through a macro to do it consistently.
>>>>
>>>>
>>>> Modified:
>>>>     trunk/channels/chan_sip.c
>>>>     trunk/include/asterisk/paths.h
>>>>     trunk/main/asterisk.c
>>>>     trunk/res/res_crypto.c
>>>>     trunk/res/res_monitor.c
>>>>     trunk/utils/ael_main.c
>>>>     trunk/utils/conf2ael.c
>>>>     trunk/utils/extconf.c
>>>>
>>> This _SETVAR macro may not be working quite as you had intended.  If you set
>>> autosystemname=yes in asterisk.conf, you'll get a segfault in main(), in the
>>> ast_copy_string() call.  I think the reason for this is that
>>> ast_config_AST_SYSTEM_NAME is being set to "" initially, and then set again later.
>>>
>> I run into the same segfault on OBSD 4.2
> 
> ok probably the compiler allocates const char foo[N] in
> readonly memory so attempts to write to it cause the trap.
> Will change the way those variables are handled:
> 
> 	static char our_AST_SYSTEM_NAME[N];
> 	const char *ast_config_AST_SYSTEM_NAME = our_AST_SYSTEM_NAME;
> 
> and write to the static variables instead.

I think it would be better to just create separate API for managing 
configuration namespace and disallow direct access to those variables 
completely.

-Maxim



More information about the asterisk-dev mailing list