[asterisk-bugs] [Asterisk 0011343]: Wrong parsing of application arguments Mysql Fetch

noreply at bugs.digium.com noreply at bugs.digium.com
Mon Dec 3 16:23:13 CST 2007


email_notification_title_for_status_bug_ready_for_testing 
====================================================================== 
http://bugs.digium.com/view.php?id=11343 
====================================================================== 
Reported By:                wegbert
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   11343
Category:                   Addons/app_addon_sql_mysql
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     ready for testing
Asterisk Version:            SVN 
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!): 487 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             11-21-2007 18:43 CST
Last Modified:              12-03-2007 16:23 CST
====================================================================== 
Summary:                    Wrong parsing of application arguments Mysql Fetch
Description: 
In function aMYSQL_fetch(struct ast_channel *chan, char *data),
after calling  AST_NONSTANDARD_APP_ARGS(args, data, ' ');
in the loop to fetch resultfields,
 s5 = strsep(&datatmp, " ");  is not working.

- It can only find one variable
- It finds really the first argument, instead from starting of with the
fourth.

My work around solutions involves copying 'data' to 'datatmp' (before
calling AST_NONSTANDARD_APP_ARGS), and shifting of the first three
arguments by calling 
strsep(&datatmp, " ");  three times:

strcpy(datatmp,ata);
strsep(&datatmp, " ");
strsep(&datatmp, " ");
strsep(&datatmp, " ");

and then using  s5 = strsep(&datatmp, " "); in the field retrieval loop.

====================================================================== 

---------------------------------------------------------------------- 
 putnopvut - 12-03-07 16:23  
---------------------------------------------------------------------- 
After looking at that code for a long while, I realized that it was bizarre
and possibly hazardous since it changes the input string. I have created a
patch for this so that a local copy of the string is created instead,
similar to what you have done in your workaround, but I decided against the
calls to strsep in favor of adding a new AST_APP_ARG to the mix.

Give the patch a try and report if it fixes the problem. Thanks for
bringing this issue to our attention! 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
12-03-07 16:23  putnopvut      Note Added: 0074709                          
12-03-07 16:23  putnopvut      Status                   new => ready for testing
======================================================================




More information about the asterisk-bugs mailing list