[Home]

Summary:ASTERISK-01942: Truncated output on -x 'database show' for large databases
Reporter:gkloepfer (gkloepfer)Labels:
Date Opened:2004-07-02 23:09:59Date Closed:2011-06-07 14:10:43
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) asterisk.c.patch
Description:Bug described in 0000183 was not fixed in CVS as of 7/1/2004, and using "asterisk -r -x 'database show'" for large databases truncates output.

There is also an unchecked boundary condition that is not handled properly in that same section of code.

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

Executing any shell-mode console command using -x that would have a large amount of output will be truncated because the remote console socket read will only allow one buffer to be read, then will exit.  There is no good way to handle this because the remote server has no consistent way of telling the client when output from a specific command has completed.

I have fixed this problem by providing a 2-second timeout on the poll when using the -x option, and not terminating the poll/socket-read/write sequence on a buffer ending with "\n" under the same conditions.  I have also commented why this is taking place.  Note that the 2-second timeout is kind of a hack in that if some command takes more than 2 seconds to execute, the output could still end up truncated.  Also, if a command is issued that sends output every second, for example, the command will never exit.  My 2-second timeout is a good compromise though, and will solve the database display problem (which is the most likely source of a command with a large amount of output).

During debugging, I also identified two unchecked boundary conditions when 0 or 1 characters are read from the remote server that will cause an underrun on the buffer, which could result in random SIGSEGVs.  I have tested for these conditions and handled them properly in the patch.

Patch is applied to asterisk/asterisk.c
Comments:By: Brian West (bkw918) 2004-07-03 00:53:57

This is a dupe of 1110.. but does it really fix the problem...doesnt sound like it.  Is this the proper way to fix it.

By: ltropiano (ltropiano) 2004-07-03 01:02:43

I have applied this patch and verified it works perfectly.

By: Mark Spencer (markster) 2004-07-03 19:07:21

I think that sounds kinda hackish.  Is there a reason you feel the existing system doesn't work?

By: mustdie (mustdie) 2004-07-03 20:36:49

The same problem applies to Manager API, which we can't fully use for now unless this problem is fixed. I have large amount of users, where i change their settings via * database. 'database show' is required for my application to behave propertly. Please fix it in proper way, so we can manage remote users propertly. This is very important for us.

By: twisted (twisted) 2004-07-03 20:58:27

Dupe of ASTERISK-1104 and ASTERISK-180. Closed. Please follow up on ASTERISK-1104.