[asterisk-commits] tilghman: branch 1.2 r61680 -
/branches/1.2/funcs/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Apr 18 19:30:18 MST 2007
Author: tilghman
Date: Wed Apr 18 21:30:18 2007
New Revision: 61680
URL: http://svn.digium.com/view/asterisk?view=rev&rev=61680
Log:
Bug 9557 - Specifying the GetVar AMI action without a Channel parameter can
cause Asterisk to crash. The reason this needs to be fixed in the functions
instead of in AMI is because Channel can legitimately be NULL, such as when
retrieving global variables.
Modified:
branches/1.2/funcs/func_callerid.c
branches/1.2/funcs/func_cdr.c
branches/1.2/funcs/func_groupcount.c
branches/1.2/funcs/func_language.c
branches/1.2/funcs/func_moh.c
branches/1.2/funcs/func_timeout.c
Modified: branches/1.2/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_callerid.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_callerid.c (original)
+++ branches/1.2/funcs/func_callerid.c Wed Apr 18 21:30:18 2007
@@ -42,6 +42,9 @@
static char *callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
+ if (!chan)
+ return "";
+
if (!strncasecmp("all", data, 3)) {
snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : "");
} else if (!strncasecmp("name", data, 4)) {
@@ -73,9 +76,9 @@
static void callerid_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
{
- if (!value)
+ if (!value || !chan)
return;
-
+
if (!strncasecmp("all", data, 3)) {
char name[256];
char num[256];
Modified: branches/1.2/funcs/func_cdr.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_cdr.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_cdr.c (original)
+++ branches/1.2/funcs/func_cdr.c Wed Apr 18 21:30:18 2007
@@ -44,7 +44,7 @@
int argc;
char *argv[2];
int recursive = 0;
- struct ast_cdr *cdr = chan->cdr;
+ struct ast_cdr *cdr = chan ? chan->cdr : NULL;
if (ast_strlen_zero(data))
return NULL;
@@ -78,9 +78,9 @@
char *argv[2];
int recursive = 0;
- if (ast_strlen_zero(data) || !value)
+ if (ast_strlen_zero(data) || !value || !chan)
return;
-
+
mydata = ast_strdupa(data);
argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
Modified: branches/1.2/funcs/func_groupcount.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_groupcount.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_groupcount.c (original)
+++ branches/1.2/funcs/func_groupcount.c Wed Apr 18 21:30:18 2007
@@ -149,6 +149,9 @@
char tmp1[1024] = "";
char tmp2[1024] = "";
+ if (!chan)
+ return "";
+
headp=&chan->varshead;
AST_LIST_TRAVERSE(headp,current,entries) {
if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
Modified: branches/1.2/funcs/func_language.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_language.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_language.c (original)
+++ branches/1.2/funcs/func_language.c Wed Apr 18 21:30:18 2007
@@ -36,14 +36,14 @@
static char *builtin_function_language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
- ast_copy_string(buf, chan->language, len);
+ ast_copy_string(buf, chan ? chan->language : "", len);
return buf;
}
static void builtin_function_language_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
{
- if (value)
+ if (chan && value)
ast_copy_string(chan->language, value, sizeof(chan->language));
}
Modified: branches/1.2/funcs/func_moh.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_moh.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_moh.c (original)
+++ branches/1.2/funcs/func_moh.c Wed Apr 18 21:30:18 2007
@@ -32,14 +32,15 @@
static char *function_moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
- ast_copy_string(buf, chan->musicclass, len);
+ ast_copy_string(buf, chan ? chan->musicclass : "", len);
return buf;
}
static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
{
- ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass));
+ if (chan)
+ ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass));
}
#ifndef BUILTIN_FUNC
Modified: branches/1.2/funcs/func_timeout.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/funcs/func_timeout.c?view=diff&rev=61680&r1=61679&r2=61680
==============================================================================
--- branches/1.2/funcs/func_timeout.c (original)
+++ branches/1.2/funcs/func_timeout.c Wed Apr 18 21:30:18 2007
@@ -42,6 +42,9 @@
{
time_t myt;
+ if (!chan)
+ return "";
+
if (!data) {
ast_log(LOG_ERROR, "Must specify type of timeout to get.\n");
return NULL;
@@ -85,6 +88,9 @@
int x;
char timestr[64];
struct tm myt;
+
+ if (!chan)
+ return;
if (!data) {
ast_log(LOG_ERROR, "Must specify type of timeout to set.\n");
More information about the asterisk-commits
mailing list