Fix dialplan function NULL channel safety issues

(closes issue ASTERISK-23391)
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3386/
........

Merged revisions 411313 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 411314 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@411315 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2014-03-27 19:15:35 +00:00
parent 2cb2ee62ae
commit 56dac4c762
31 changed files with 315 additions and 30 deletions

View File

@@ -1535,7 +1535,7 @@ static int features_pre_apply_config(void)
return err;
}
static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
static int internal_feature_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
int res;
@@ -1566,7 +1566,7 @@ static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
return res;
}
static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
static int internal_feature_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
int res;
@@ -1596,7 +1596,7 @@ static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
return res;
}
static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
static int internal_featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
int res;
@@ -1611,7 +1611,7 @@ static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data
return res;
}
static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
static int internal_featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
int res;
@@ -1631,6 +1631,50 @@ static int featuremap_write(struct ast_channel *chan, const char *cmd, char *dat
return 0;
}
static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
if (!chan) {
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
return -1;
}
return internal_feature_read(chan, cmd, data, buf, len);
}
static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
if (!chan) {
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
return -1;
}
return internal_feature_write(chan, cmd, data, value);
}
static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
if (!chan) {
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
return -1;
}
return internal_featuremap_read(chan, cmd, data, buf, len);
}
static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
if (!chan) {
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
return -1;
}
return internal_featuremap_write(chan, cmd, data, value);
}
static struct ast_custom_function feature_function = {
.name = "FEATURE",
.read = feature_read,