[Home]

Summary:ASTERISK-17208: [patch] Read func CHANNEL() on sip channel without arg will crash asterisk
Reporter:Wolfgang Pichler (wuwu)Labels:
Date Opened:2011-01-21 01:04:10.000-0600Date Closed:2011-03-08 14:34:07.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) diff.patch
Description:calling the function CHANNEL() without an argument on a sip channel will crash asterisk with a segfault.
In sip_acf_channel_read it does parse arguments - and then starts a strcasecmp on the args.param - but args is invalid / null - because there are no arguments.

Adding a ast_strlen_zero check at the beginning should resolv the problem - untested code is at the additional information...

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

int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
{
       struct sip_pvt *p = chan->tech_pvt;
       char *parse = ast_strdupa(preparse);
       int res = 0;
       /* Check for zero arguments */
       if (ast_strlen_zero(parse)) {
               ast_log(LOG_ERROR, "Cannot call %s without arguments\n", funcname);
               return 0;
       }
       AST_DECLARE_APP_ARGS(args,
               AST_APP_ARG(param);
               AST_APP_ARG(type);
               AST_APP_ARG(field);
       );
       AST_STANDARD_APP_ARGS(args, parse);
Comments:By: Jonathan Rose (jrose) 2011-03-08 13:39:44.000-0600

Verified the bug, applied and tested your fix.  It works and it seems like the sensible way to do it.

By the way, you can submit these as patches if you check out from SVN.  It makes the whole process of applying and committing a little smoother.  Good spot though and thanks for the help.



By: Digium Subversion (svnbot) 2011-03-08 14:19:34.000-0600

Repository: asterisk
Revision: 310088

U   branches/1.8/channels/sip/dialplan_functions.c

------------------------------------------------------------------------
r310088 | jrose | 2011-03-08 14:19:33 -0600 (Tue, 08 Mar 2011) | 9 lines

Returns with an error notice if CHANNEL function of SIP channel is read without arguments.

(Closes issue ASTERISK-17208)
Reported by: wuwu
Patches:
     diff.patch uploaded by jrose (license 1225)
Tested by: jrose


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

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

By: Digium Subversion (svnbot) 2011-03-08 14:34:06.000-0600

Repository: asterisk
Revision: 310089

_U  trunk/
U   trunk/channels/sip/dialplan_functions.c

------------------------------------------------------------------------
r310089 | jrose | 2011-03-08 14:34:06 -0600 (Tue, 08 Mar 2011) | 15 lines

Merged revisions 310088 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
 r310088 | jrose | 2011-03-08 14:19:32 -0600 (Tue, 08 Mar 2011) | 9 lines
 
 Returns with an error notice if CHANNEL function of SIP channel is read without arguments.
 
 (Closes issue ASTERISK-17208)
 Reported by: wuwu
 Patches:
       diff.patch uploaded by jrose (license 1225)
 Tested by: jrose
........

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

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