[asterisk-dev] Segmentation fault (core dumped) on custom application execution

Yukio Tanaka Yukio at starcb.com
Fri Aug 18 02:38:12 CDT 2017


Hello,

I am in the process of writing an application for my server. Compilation and installation run without a hitch. However at runtime the application provokes a "Segmentation fault (core dumped)" which shuts down my server. I am clueless as to what sends the error and even more so on how to fix it so any help would be appreciated. Below is a copy of my code.

Thanks in advance for any help.
Yukio


/***
* Send File (app_sendfile.c) by Yukio Tanaka (yukio at starcb.com)
*
 * Use at the end of the dialplan in a monitored call. This will:
*   a) Add call metadatas to the monitor file.
*   b) Send the file to the specified server using ssh.
*
 ******
* Version 0.1 - 2017.07
*
 * - Testing metadata hard writing for the moment
* /!\ At runtime encountering error: Segmentation fault (core dumped)
***/

#include "asterisk.h"
/*ASTERISK_FILE_VERSION(__FILE__, "$Revision$")*/

#include "asterisk/cdr.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/pbx.h"

/* Use id3v2 application to add an author metadata */
const char ID3V2_COMMAND[]= "id3v2 -a \"Algernopp Krieger\" ";

static int sendfile_exec(struct ast_channel *chan, const char *data)
{
   size_t fnameLength= strlen(pbx_builtin_getvar_helper(chan, "MIXMONITOR_FILENAME"));
   char fileName[fnameLength];
   strcpy(fileName, pbx_builtin_getvar_helper(chan, "MIXMONITOR_FILENAME"));
   char fullCommand[1]= "\0";
   strcat(fullCommand, ID3V2_COMMAND);
   strcat(fullCommand, fileName);
  system(fullCommand);

   return 1;
}

static int load_module(void)
{
  ast_register_application("SendFile", sendfile_exec, "Send a recorded call to a server.", "Some description.");


  return AST_MODULE_LOAD_SUCCESS;
}

static int unload_module(void)
{
  ast_cdr_unregister("SendFile");
  return 0;
}

AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SendFile")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20170818/f89ef0e3/attachment.html>


More information about the asterisk-dev mailing list