mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
more ast_copy_string() conversion
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
18
app.c
18
app.c
@@ -384,7 +384,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in
|
|||||||
return -1;
|
return -1;
|
||||||
autoclose = 1;
|
autoclose = 1;
|
||||||
if (filename[0] == '/')
|
if (filename[0] == '/')
|
||||||
strncpy(tmpf, filename, sizeof(tmpf) - 1);
|
ast_copy_string(tmpf, filename, sizeof(tmpf));
|
||||||
else
|
else
|
||||||
snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_VAR_DIR, "sounds", filename);
|
snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_VAR_DIR, "sounds", filename);
|
||||||
fd = open(tmpf, O_RDONLY);
|
fd = open(tmpf, O_RDONLY);
|
||||||
@@ -773,7 +773,7 @@ int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordf
|
|||||||
if (d < 0)
|
if (d < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(prependfile, recordfile, sizeof(prependfile) -1);
|
ast_copy_string(prependfile, recordfile, sizeof(prependfile));
|
||||||
strncat(prependfile, "-prepend", sizeof(prependfile) - strlen(prependfile) - 1);
|
strncat(prependfile, "-prepend", sizeof(prependfile) - strlen(prependfile) - 1);
|
||||||
|
|
||||||
fmts = ast_strdupa(fmt);
|
fmts = ast_strdupa(fmt);
|
||||||
@@ -971,7 +971,7 @@ int ast_app_group_split_group(char *data, char *group, int group_max, char *cate
|
|||||||
char *grp=NULL, *cat=NULL;
|
char *grp=NULL, *cat=NULL;
|
||||||
|
|
||||||
if (data && !ast_strlen_zero(data)) {
|
if (data && !ast_strlen_zero(data)) {
|
||||||
strncpy(tmp, data, sizeof(tmp) - 1);
|
ast_copy_string(tmp, data, sizeof(tmp));
|
||||||
grp = tmp;
|
grp = tmp;
|
||||||
cat = strchr(tmp, '@');
|
cat = strchr(tmp, '@');
|
||||||
if (cat) {
|
if (cat) {
|
||||||
@@ -981,14 +981,14 @@ int ast_app_group_split_group(char *data, char *group, int group_max, char *cate
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (grp && !ast_strlen_zero(grp))
|
if (grp && !ast_strlen_zero(grp))
|
||||||
strncpy(group, grp, group_max -1);
|
ast_copy_string(group, grp, group_max);
|
||||||
else
|
else
|
||||||
res = -1;
|
res = -1;
|
||||||
|
|
||||||
if (cat)
|
if (cat)
|
||||||
snprintf(category, category_max, "%s_%s", GROUP_CATEGORY_PREFIX, cat);
|
snprintf(category, category_max, "%s_%s", GROUP_CATEGORY_PREFIX, cat);
|
||||||
else
|
else
|
||||||
strncpy(category, GROUP_CATEGORY_PREFIX, category_max - 1);
|
ast_copy_string(category, GROUP_CATEGORY_PREFIX, category_max);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -1015,9 +1015,9 @@ int ast_app_group_get_count(char *group, char *category)
|
|||||||
char cat[80] = "";
|
char cat[80] = "";
|
||||||
|
|
||||||
if (category && !ast_strlen_zero(category)) {
|
if (category && !ast_strlen_zero(category)) {
|
||||||
strncpy(cat, category, sizeof(cat) - 1);
|
ast_copy_string(cat, category, sizeof(cat));
|
||||||
} else {
|
} else {
|
||||||
strncpy(cat, GROUP_CATEGORY_PREFIX, sizeof(cat) - 1);
|
ast_copy_string(cat, GROUP_CATEGORY_PREFIX, sizeof(cat));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group && !ast_strlen_zero(group)) {
|
if (group && !ast_strlen_zero(group)) {
|
||||||
@@ -1050,9 +1050,9 @@ int ast_app_group_match_get_count(char *groupmatch, char *category)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (category && !ast_strlen_zero(category)) {
|
if (category && !ast_strlen_zero(category)) {
|
||||||
strncpy(cat, category, sizeof(cat) - 1);
|
ast_copy_string(cat, category, sizeof(cat));
|
||||||
} else {
|
} else {
|
||||||
strncpy(cat, GROUP_CATEGORY_PREFIX, sizeof(cat) - 1);
|
ast_copy_string(cat, GROUP_CATEGORY_PREFIX, sizeof(cat));
|
||||||
}
|
}
|
||||||
|
|
||||||
chan = ast_channel_walk_locked(NULL);
|
chan = ast_channel_walk_locked(NULL);
|
||||||
|
48
asterisk.c
48
asterisk.c
@@ -282,7 +282,7 @@ static void *netconsole(void *vconsole)
|
|||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
|
|
||||||
if (gethostname(hostname, sizeof(hostname)-1))
|
if (gethostname(hostname, sizeof(hostname)-1))
|
||||||
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
|
||||||
snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, ASTERISK_VERSION);
|
snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, ASTERISK_VERSION);
|
||||||
fdprint(con->fd, tmp);
|
fdprint(con->fd, tmp);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
@@ -413,7 +413,7 @@ static int ast_makesocket(void)
|
|||||||
}
|
}
|
||||||
memset(&sunaddr, 0, sizeof(sunaddr));
|
memset(&sunaddr, 0, sizeof(sunaddr));
|
||||||
sunaddr.sun_family = AF_LOCAL;
|
sunaddr.sun_family = AF_LOCAL;
|
||||||
strncpy(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path)-1);
|
ast_copy_string(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path));
|
||||||
res = bind(ast_socket, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
|
res = bind(ast_socket, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_log(LOG_WARNING, "Unable to bind socket to %s: %s\n", (char *)ast_config_AST_SOCKET, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to bind socket to %s: %s\n", (char *)ast_config_AST_SOCKET, strerror(errno));
|
||||||
@@ -486,7 +486,7 @@ static int ast_tryconnect(void)
|
|||||||
}
|
}
|
||||||
memset(&sunaddr, 0, sizeof(sunaddr));
|
memset(&sunaddr, 0, sizeof(sunaddr));
|
||||||
sunaddr.sun_family = AF_LOCAL;
|
sunaddr.sun_family = AF_LOCAL;
|
||||||
strncpy(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path)-1);
|
ast_copy_string(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path));
|
||||||
res = connect(ast_consock, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
|
res = connect(ast_consock, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
|
||||||
if (res) {
|
if (res) {
|
||||||
close(ast_consock);
|
close(ast_consock);
|
||||||
@@ -1558,17 +1558,17 @@ static void ast_readconfig(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* init with buildtime config */
|
/* init with buildtime config */
|
||||||
strncpy((char *)ast_config_AST_CONFIG_DIR,AST_CONFIG_DIR,sizeof(ast_config_AST_CONFIG_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_CONFIG_DIR,AST_CONFIG_DIR,sizeof(ast_config_AST_CONFIG_DIR));
|
||||||
strncpy((char *)ast_config_AST_SPOOL_DIR,AST_SPOOL_DIR,sizeof(ast_config_AST_SPOOL_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_SPOOL_DIR,AST_SPOOL_DIR,sizeof(ast_config_AST_SPOOL_DIR));
|
||||||
strncpy((char *)ast_config_AST_MODULE_DIR,AST_MODULE_DIR,sizeof(ast_config_AST_VAR_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_MODULE_DIR,AST_MODULE_DIR,sizeof(ast_config_AST_VAR_DIR));
|
||||||
strncpy((char *)ast_config_AST_VAR_DIR,AST_VAR_DIR,sizeof(ast_config_AST_VAR_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_VAR_DIR,AST_VAR_DIR,sizeof(ast_config_AST_VAR_DIR));
|
||||||
strncpy((char *)ast_config_AST_LOG_DIR,AST_LOG_DIR,sizeof(ast_config_AST_LOG_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_LOG_DIR,AST_LOG_DIR,sizeof(ast_config_AST_LOG_DIR));
|
||||||
strncpy((char *)ast_config_AST_AGI_DIR,AST_AGI_DIR,sizeof(ast_config_AST_AGI_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_AGI_DIR,AST_AGI_DIR,sizeof(ast_config_AST_AGI_DIR));
|
||||||
strncpy((char *)ast_config_AST_DB,AST_DB,sizeof(ast_config_AST_DB)-1);
|
ast_copy_string((char *)ast_config_AST_DB,AST_DB,sizeof(ast_config_AST_DB));
|
||||||
strncpy((char *)ast_config_AST_KEY_DIR,AST_KEY_DIR,sizeof(ast_config_AST_KEY_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_KEY_DIR,AST_KEY_DIR,sizeof(ast_config_AST_KEY_DIR));
|
||||||
strncpy((char *)ast_config_AST_PID,AST_PID,sizeof(ast_config_AST_PID)-1);
|
ast_copy_string((char *)ast_config_AST_PID,AST_PID,sizeof(ast_config_AST_PID));
|
||||||
strncpy((char *)ast_config_AST_SOCKET,AST_SOCKET,sizeof(ast_config_AST_SOCKET)-1);
|
ast_copy_string((char *)ast_config_AST_SOCKET,AST_SOCKET,sizeof(ast_config_AST_SOCKET));
|
||||||
strncpy((char *)ast_config_AST_RUN_DIR,AST_RUN_DIR,sizeof(ast_config_AST_RUN_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_RUN_DIR,AST_RUN_DIR,sizeof(ast_config_AST_RUN_DIR));
|
||||||
|
|
||||||
/* no asterisk.conf? no problem, use buildtime config! */
|
/* no asterisk.conf? no problem, use buildtime config! */
|
||||||
if (!cfg) {
|
if (!cfg) {
|
||||||
@@ -1585,22 +1585,22 @@ static void ast_readconfig(void) {
|
|||||||
v = ast_variable_browse(cfg, "directories");
|
v = ast_variable_browse(cfg, "directories");
|
||||||
while(v) {
|
while(v) {
|
||||||
if (!strcasecmp(v->name, "astetcdir")) {
|
if (!strcasecmp(v->name, "astetcdir")) {
|
||||||
strncpy((char *)ast_config_AST_CONFIG_DIR,v->value,sizeof(ast_config_AST_CONFIG_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_CONFIG_DIR,v->value,sizeof(ast_config_AST_CONFIG_DIR));
|
||||||
} else if (!strcasecmp(v->name, "astspooldir")) {
|
} else if (!strcasecmp(v->name, "astspooldir")) {
|
||||||
strncpy((char *)ast_config_AST_SPOOL_DIR,v->value,sizeof(ast_config_AST_SPOOL_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_SPOOL_DIR,v->value,sizeof(ast_config_AST_SPOOL_DIR));
|
||||||
} else if (!strcasecmp(v->name, "astvarlibdir")) {
|
} else if (!strcasecmp(v->name, "astvarlibdir")) {
|
||||||
strncpy((char *)ast_config_AST_VAR_DIR,v->value,sizeof(ast_config_AST_VAR_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_VAR_DIR,v->value,sizeof(ast_config_AST_VAR_DIR));
|
||||||
snprintf((char *)ast_config_AST_DB,sizeof(ast_config_AST_DB),"%s/%s",v->value,"astdb");
|
snprintf((char *)ast_config_AST_DB,sizeof(ast_config_AST_DB),"%s/%s",v->value,"astdb");
|
||||||
} else if (!strcasecmp(v->name, "astlogdir")) {
|
} else if (!strcasecmp(v->name, "astlogdir")) {
|
||||||
strncpy((char *)ast_config_AST_LOG_DIR,v->value,sizeof(ast_config_AST_LOG_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_LOG_DIR,v->value,sizeof(ast_config_AST_LOG_DIR));
|
||||||
} else if (!strcasecmp(v->name, "astagidir")) {
|
} else if (!strcasecmp(v->name, "astagidir")) {
|
||||||
strncpy((char *)ast_config_AST_AGI_DIR,v->value,sizeof(ast_config_AST_AGI_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_AGI_DIR,v->value,sizeof(ast_config_AST_AGI_DIR));
|
||||||
} else if (!strcasecmp(v->name, "astrundir")) {
|
} else if (!strcasecmp(v->name, "astrundir")) {
|
||||||
snprintf((char *)ast_config_AST_PID,sizeof(ast_config_AST_PID),"%s/%s",v->value,"asterisk.pid");
|
snprintf((char *)ast_config_AST_PID,sizeof(ast_config_AST_PID),"%s/%s",v->value,"asterisk.pid");
|
||||||
snprintf((char *)ast_config_AST_SOCKET,sizeof(ast_config_AST_SOCKET),"%s/%s",v->value,v_ctlfile==NULL?"asterisk.ctl":v_ctlfile->value);
|
snprintf((char *)ast_config_AST_SOCKET,sizeof(ast_config_AST_SOCKET),"%s/%s",v->value,v_ctlfile==NULL?"asterisk.ctl":v_ctlfile->value);
|
||||||
strncpy((char *)ast_config_AST_RUN_DIR,v->value,sizeof(ast_config_AST_RUN_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_RUN_DIR,v->value,sizeof(ast_config_AST_RUN_DIR));
|
||||||
} else if (!strcasecmp(v->name, "astmoddir")) {
|
} else if (!strcasecmp(v->name, "astmoddir")) {
|
||||||
strncpy((char *)ast_config_AST_MODULE_DIR,v->value,sizeof(ast_config_AST_MODULE_DIR)-1);
|
ast_copy_string((char *)ast_config_AST_MODULE_DIR,v->value,sizeof(ast_config_AST_MODULE_DIR));
|
||||||
}
|
}
|
||||||
v = v->next;
|
v = v->next;
|
||||||
}
|
}
|
||||||
@@ -1650,7 +1650,7 @@ static void ast_readconfig(void) {
|
|||||||
option_cache_record_files = ast_true(v->value);
|
option_cache_record_files = ast_true(v->value);
|
||||||
/* Specify cache directory */
|
/* Specify cache directory */
|
||||||
} else if (!strcasecmp(v->name, "record_cache_dir")) {
|
} else if (!strcasecmp(v->name, "record_cache_dir")) {
|
||||||
strncpy(record_cache_dir,v->value,AST_CACHE_DIR_LEN);
|
ast_copy_string(record_cache_dir,v->value,AST_CACHE_DIR_LEN);
|
||||||
/* Build transcode paths via SLINEAR, instead of directly */
|
/* Build transcode paths via SLINEAR, instead of directly */
|
||||||
} else if (!strcasecmp(v->name, "transcode_via_sln")) {
|
} else if (!strcasecmp(v->name, "transcode_via_sln")) {
|
||||||
option_transcode_slin = ast_true(v->value);
|
option_transcode_slin = ast_true(v->value);
|
||||||
@@ -1694,7 +1694,7 @@ int main(int argc, char *argv[])
|
|||||||
option_nofork++;
|
option_nofork++;
|
||||||
}
|
}
|
||||||
if (gethostname(hostname, sizeof(hostname)-1))
|
if (gethostname(hostname, sizeof(hostname)-1))
|
||||||
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
|
||||||
ast_mainpid = getpid();
|
ast_mainpid = getpid();
|
||||||
ast_ulaw_init();
|
ast_ulaw_init();
|
||||||
ast_alaw_init();
|
ast_alaw_init();
|
||||||
@@ -1761,7 +1761,7 @@ int main(int argc, char *argv[])
|
|||||||
xarg = optarg;
|
xarg = optarg;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
strncpy((char *)ast_config_AST_CONFIG_FILE,optarg,sizeof(ast_config_AST_CONFIG_FILE) - 1);
|
ast_copy_string((char *)ast_config_AST_CONFIG_FILE,optarg,sizeof(ast_config_AST_CONFIG_FILE));
|
||||||
option_overrideconfig++;
|
option_overrideconfig++;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
|
38
channel.c
38
channel.c
@@ -393,7 +393,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
|
|||||||
tmp->fds[AST_MAX_FDS-1] = tmp->alertpipe[0];
|
tmp->fds[AST_MAX_FDS-1] = tmp->alertpipe[0];
|
||||||
/* And timing pipe */
|
/* And timing pipe */
|
||||||
tmp->fds[AST_MAX_FDS-2] = tmp->timingfd;
|
tmp->fds[AST_MAX_FDS-2] = tmp->timingfd;
|
||||||
strncpy(tmp->name, "**Unknown**", sizeof(tmp->name)-1);
|
ast_copy_string(tmp->name, "**Unknown**", sizeof(tmp->name));
|
||||||
/* Initial state */
|
/* Initial state */
|
||||||
tmp->_state = AST_STATE_DOWN;
|
tmp->_state = AST_STATE_DOWN;
|
||||||
tmp->streamid = -1;
|
tmp->streamid = -1;
|
||||||
@@ -405,12 +405,12 @@ struct ast_channel *ast_channel_alloc(int needqueue)
|
|||||||
headp = &tmp->varshead;
|
headp = &tmp->varshead;
|
||||||
ast_mutex_init(&tmp->lock);
|
ast_mutex_init(&tmp->lock);
|
||||||
AST_LIST_HEAD_INIT(headp);
|
AST_LIST_HEAD_INIT(headp);
|
||||||
strncpy(tmp->context, "default", sizeof(tmp->context)-1);
|
ast_copy_string(tmp->context, "default", sizeof(tmp->context));
|
||||||
strncpy(tmp->language, defaultlanguage, sizeof(tmp->language)-1);
|
ast_copy_string(tmp->language, defaultlanguage, sizeof(tmp->language));
|
||||||
strncpy(tmp->exten, "s", sizeof(tmp->exten)-1);
|
ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
|
||||||
tmp->priority = 1;
|
tmp->priority = 1;
|
||||||
tmp->amaflags = ast_default_amaflags;
|
tmp->amaflags = ast_default_amaflags;
|
||||||
strncpy(tmp->accountcode, ast_default_accountcode, sizeof(tmp->accountcode)-1);
|
ast_copy_string(tmp->accountcode, ast_default_accountcode, sizeof(tmp->accountcode));
|
||||||
|
|
||||||
tmp->tech = &null_tech;
|
tmp->tech = &null_tech;
|
||||||
|
|
||||||
@@ -674,7 +674,7 @@ void ast_channel_free(struct ast_channel *chan)
|
|||||||
free(chan->tech_pvt);
|
free(chan->tech_pvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(name, chan->name, sizeof(name)-1);
|
ast_copy_string(name, chan->name, sizeof(name));
|
||||||
|
|
||||||
/* Stop monitoring */
|
/* Stop monitoring */
|
||||||
if (chan->monitor) {
|
if (chan->monitor) {
|
||||||
@@ -1994,9 +1994,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, void *d
|
|||||||
/* Final fixups */
|
/* Final fixups */
|
||||||
if (oh) {
|
if (oh) {
|
||||||
if (oh->context && *oh->context)
|
if (oh->context && *oh->context)
|
||||||
strncpy(chan->context, oh->context, sizeof(chan->context) - 1);
|
ast_copy_string(chan->context, oh->context, sizeof(chan->context));
|
||||||
if (oh->exten && *oh->exten)
|
if (oh->exten && *oh->exten)
|
||||||
strncpy(chan->exten, oh->exten, sizeof(chan->exten) - 1);
|
ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
|
||||||
chan->priority = oh->priority;
|
chan->priority = oh->priority;
|
||||||
}
|
}
|
||||||
if (chan->_state == AST_STATE_UP)
|
if (chan->_state == AST_STATE_UP)
|
||||||
@@ -2093,7 +2093,7 @@ int ast_parse_device_state(char *device)
|
|||||||
|
|
||||||
chan = ast_channel_walk_locked(NULL);
|
chan = ast_channel_walk_locked(NULL);
|
||||||
while (chan) {
|
while (chan) {
|
||||||
strncpy(name, chan->name, sizeof(name)-1);
|
ast_copy_string(name, chan->name, sizeof(name));
|
||||||
ast_mutex_unlock(&chan->lock);
|
ast_mutex_unlock(&chan->lock);
|
||||||
cut = strchr(name,'-');
|
cut = strchr(name,'-');
|
||||||
if (cut)
|
if (cut)
|
||||||
@@ -2117,7 +2117,7 @@ int ast_device_state(char *device)
|
|||||||
struct chanlist *chanls;
|
struct chanlist *chanls;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
strncpy(tech, device, sizeof(tech)-1);
|
ast_copy_string(tech, device, sizeof(tech));
|
||||||
number = strchr(tech, '/');
|
number = strchr(tech, '/');
|
||||||
if (!number) {
|
if (!number) {
|
||||||
return AST_DEVICE_INVALID;
|
return AST_DEVICE_INVALID;
|
||||||
@@ -2373,8 +2373,8 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
|
|||||||
void ast_change_name(struct ast_channel *chan, char *newname)
|
void ast_change_name(struct ast_channel *chan, char *newname)
|
||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
strncpy(tmp, chan->name, sizeof(tmp) - 1);
|
ast_copy_string(tmp, chan->name, sizeof(tmp));
|
||||||
strncpy(chan->name, newname, sizeof(chan->name) - 1);
|
ast_copy_string(chan->name, newname, sizeof(chan->name));
|
||||||
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", tmp, chan->name, chan->uniqueid);
|
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", tmp, chan->name, chan->uniqueid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2495,17 +2495,17 @@ int ast_do_masquerade(struct ast_channel *original)
|
|||||||
clone->masqr = NULL;
|
clone->masqr = NULL;
|
||||||
|
|
||||||
/* Save the original name */
|
/* Save the original name */
|
||||||
strncpy(orig, original->name, sizeof(orig) - 1);
|
ast_copy_string(orig, original->name, sizeof(orig));
|
||||||
/* Save the new name */
|
/* Save the new name */
|
||||||
strncpy(newn, clone->name, sizeof(newn) - 1);
|
ast_copy_string(newn, clone->name, sizeof(newn));
|
||||||
/* Create the masq name */
|
/* Create the masq name */
|
||||||
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
|
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
|
||||||
|
|
||||||
/* Copy the name from the clone channel */
|
/* Copy the name from the clone channel */
|
||||||
strncpy(original->name, newn, sizeof(original->name)-1);
|
ast_copy_string(original->name, newn, sizeof(original->name));
|
||||||
|
|
||||||
/* Mangle the name of the clone channel */
|
/* Mangle the name of the clone channel */
|
||||||
strncpy(clone->name, masqn, sizeof(clone->name) - 1);
|
ast_copy_string(clone->name, masqn, sizeof(clone->name));
|
||||||
|
|
||||||
/* Notify any managers of the change, first the masq then the other */
|
/* Notify any managers of the change, first the masq then the other */
|
||||||
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
|
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
|
||||||
@@ -2589,14 +2589,14 @@ int ast_do_masquerade(struct ast_channel *original)
|
|||||||
|
|
||||||
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
|
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
|
||||||
/* Mangle the name of the clone channel */
|
/* Mangle the name of the clone channel */
|
||||||
strncpy(clone->name, zombn, sizeof(clone->name) - 1);
|
ast_copy_string(clone->name, zombn, sizeof(clone->name));
|
||||||
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
|
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
|
||||||
|
|
||||||
/* Update the type. */
|
/* Update the type. */
|
||||||
original->type = clone->type;
|
original->type = clone->type;
|
||||||
|
|
||||||
/* Keep the same language. */
|
/* Keep the same language. */
|
||||||
strncpy(original->language, clone->language, sizeof(original->language));
|
ast_copy_string(original->language, clone->language, sizeof(original->language));
|
||||||
/* Copy the FD's */
|
/* Copy the FD's */
|
||||||
for (x=0;x<AST_MAX_FDS;x++) {
|
for (x=0;x<AST_MAX_FDS;x++) {
|
||||||
original->fds[x] = clone->fds[x];
|
original->fds[x] = clone->fds[x];
|
||||||
@@ -2638,7 +2638,7 @@ int ast_do_masquerade(struct ast_channel *original)
|
|||||||
ast_set_read_format(original, rformat);
|
ast_set_read_format(original, rformat);
|
||||||
|
|
||||||
/* Copy the music class */
|
/* Copy the music class */
|
||||||
strncpy(original->musicclass, clone->musicclass, sizeof(original->musicclass) - 1);
|
ast_copy_string(original->musicclass, clone->musicclass, sizeof(original->musicclass));
|
||||||
|
|
||||||
ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
|
ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
|
||||||
|
|
||||||
|
22
file.c
22
file.c
@@ -119,8 +119,8 @@ int ast_format_register(const char *name, const char *exts, int format,
|
|||||||
ast_mutex_unlock(&formatlock);
|
ast_mutex_unlock(&formatlock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tmp->name, name, sizeof(tmp->name)-1);
|
ast_copy_string(tmp->name, name, sizeof(tmp->name));
|
||||||
strncpy(tmp->exts, exts, sizeof(tmp->exts)-1);
|
ast_copy_string(tmp->exts, exts, sizeof(tmp->exts));
|
||||||
tmp->open = open;
|
tmp->open = open;
|
||||||
tmp->rewrite = rewrite;
|
tmp->rewrite = rewrite;
|
||||||
tmp->read = read;
|
tmp->read = read;
|
||||||
@@ -285,9 +285,9 @@ static char *build_filename(const char *filename, const char *ext)
|
|||||||
int fnsize = 0;
|
int fnsize = 0;
|
||||||
|
|
||||||
if (!strcmp(ext, "wav49")) {
|
if (!strcmp(ext, "wav49")) {
|
||||||
strncpy(type, "WAV", sizeof(type) - 1);
|
ast_copy_string(type, "WAV", sizeof(type));
|
||||||
} else {
|
} else {
|
||||||
strncpy(type, ext, sizeof(type) - 1);
|
ast_copy_string(type, ext, sizeof(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename[0] == '/') {
|
if (filename[0] == '/') {
|
||||||
@@ -313,7 +313,7 @@ static int exts_compare(const char *exts, const char *type)
|
|||||||
char *stringp = NULL, *ext;
|
char *stringp = NULL, *ext;
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
|
|
||||||
strncpy(tmp, exts, sizeof(tmp) - 1);
|
ast_copy_string(tmp, exts, sizeof(tmp));
|
||||||
stringp = tmp;
|
stringp = tmp;
|
||||||
while ((ext = strsep(&stringp, "|"))) {
|
while ((ext = strsep(&stringp, "|"))) {
|
||||||
if (!strcmp(ext, type)) {
|
if (!strcmp(ext, type)) {
|
||||||
@@ -472,7 +472,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
|
|||||||
ast_deactivate_generator(chan);
|
ast_deactivate_generator(chan);
|
||||||
}
|
}
|
||||||
if (preflang && !ast_strlen_zero(preflang)) {
|
if (preflang && !ast_strlen_zero(preflang)) {
|
||||||
strncpy(filename3, filename, sizeof(filename3) - 1);
|
ast_copy_string(filename3, filename, sizeof(filename3));
|
||||||
endpart = strrchr(filename3, '/');
|
endpart = strrchr(filename3, '/');
|
||||||
if (endpart) {
|
if (endpart) {
|
||||||
*endpart = '\0';
|
*endpart = '\0';
|
||||||
@@ -483,7 +483,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
|
|||||||
fmts = ast_fileexists(filename2, NULL, NULL);
|
fmts = ast_fileexists(filename2, NULL, NULL);
|
||||||
}
|
}
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
strncpy(filename2, filename, sizeof(filename2)-1);
|
ast_copy_string(filename2, filename, sizeof(filename2));
|
||||||
fmts = ast_fileexists(filename2, NULL, NULL);
|
fmts = ast_fileexists(filename2, NULL, NULL);
|
||||||
}
|
}
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
@@ -524,13 +524,13 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
|
|||||||
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
|
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
|
||||||
fmts = ast_fileexists(filename2, fmt, NULL);
|
fmts = ast_fileexists(filename2, fmt, NULL);
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
strncpy(lang2, preflang, sizeof(lang2)-1);
|
ast_copy_string(lang2, preflang, sizeof(lang2));
|
||||||
snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
|
snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
|
||||||
fmts = ast_fileexists(filename2, fmt, NULL);
|
fmts = ast_fileexists(filename2, fmt, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
strncpy(filename2, filename, sizeof(filename2)-1);
|
ast_copy_string(filename2, filename, sizeof(filename2));
|
||||||
fmts = ast_fileexists(filename2, fmt, NULL);
|
fmts = ast_fileexists(filename2, fmt, NULL);
|
||||||
}
|
}
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
@@ -723,7 +723,7 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
if (preflang && !ast_strlen_zero(preflang)) {
|
if (preflang && !ast_strlen_zero(preflang)) {
|
||||||
/* Insert the language between the last two parts of the path */
|
/* Insert the language between the last two parts of the path */
|
||||||
strncpy(tmp, filename, sizeof(tmp) - 1);
|
ast_copy_string(tmp, filename, sizeof(tmp));
|
||||||
c = strrchr(tmp, '/');
|
c = strrchr(tmp, '/');
|
||||||
if (c) {
|
if (c) {
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
@@ -738,7 +738,7 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
|
|||||||
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
|
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
|
||||||
if (res < 1) {
|
if (res < 1) {
|
||||||
char *stringp=NULL;
|
char *stringp=NULL;
|
||||||
strncpy(lang2, preflang, sizeof(lang2)-1);
|
ast_copy_string(lang2, preflang, sizeof(lang2));
|
||||||
stringp=lang2;
|
stringp=lang2;
|
||||||
strsep(&stringp, "_");
|
strsep(&stringp, "_");
|
||||||
/* If language is a specific locality of a language (like es_MX), strip the locality and try again */
|
/* If language is a specific locality of a language (like es_MX), strip the locality and try again */
|
||||||
|
103
pbx.c
103
pbx.c
@@ -913,7 +913,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
headp=&c->varshead;
|
headp=&c->varshead;
|
||||||
*ret=NULL;
|
*ret=NULL;
|
||||||
if ((first=strchr(var,':'))) { /* : Remove characters counting from end or start of string */
|
if ((first=strchr(var,':'))) { /* : Remove characters counting from end or start of string */
|
||||||
strncpy(tmpvar, var, sizeof(tmpvar) - 1);
|
ast_copy_string(tmpvar, var, sizeof(tmpvar));
|
||||||
first = strchr(tmpvar, ':');
|
first = strchr(tmpvar, ':');
|
||||||
if (!first)
|
if (!first)
|
||||||
first = tmpvar + strlen(tmpvar);
|
first = tmpvar + strlen(tmpvar);
|
||||||
@@ -959,25 +959,25 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
if (c->cid.cid_name) {
|
if (c->cid.cid_name) {
|
||||||
snprintf(workspace, workspacelen, "\"%s\" <%s>", c->cid.cid_name, c->cid.cid_num);
|
snprintf(workspace, workspacelen, "\"%s\" <%s>", c->cid.cid_name, c->cid.cid_num);
|
||||||
} else {
|
} else {
|
||||||
strncpy(workspace, c->cid.cid_num, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_num, workspacelen);
|
||||||
}
|
}
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c->cid.cid_name) {
|
} else if (c->cid.cid_name) {
|
||||||
strncpy(workspace, c->cid.cid_name, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_name, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
} else if (!strcmp(var + 8, "NUM")) {
|
} else if (!strcmp(var + 8, "NUM")) {
|
||||||
/* CALLERIDNUM */
|
/* CALLERIDNUM */
|
||||||
if (c->cid.cid_num) {
|
if (c->cid.cid_num) {
|
||||||
strncpy(workspace, c->cid.cid_num, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_num, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
} else if (!strcmp(var + 8, "NAME")) {
|
} else if (!strcmp(var + 8, "NAME")) {
|
||||||
/* CALLERIDNAME */
|
/* CALLERIDNAME */
|
||||||
if (c->cid.cid_name) {
|
if (c->cid.cid_name) {
|
||||||
strncpy(workspace, c->cid.cid_name, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_name, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
@@ -985,7 +985,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
} else if (!strcmp(var + 6, "ANI")) {
|
} else if (!strcmp(var + 6, "ANI")) {
|
||||||
/* CALLERANI */
|
/* CALLERANI */
|
||||||
if (c->cid.cid_ani) {
|
if (c->cid.cid_ani) {
|
||||||
strncpy(workspace, c->cid.cid_ani, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_ani, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
@@ -1014,7 +1014,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
goto icky;
|
goto icky;
|
||||||
} else if (c && !strcmp(var, "DNID")) {
|
} else if (c && !strcmp(var, "DNID")) {
|
||||||
if (c->cid.cid_dnid) {
|
if (c->cid.cid_dnid) {
|
||||||
strncpy(workspace, c->cid.cid_dnid, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_dnid, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
@@ -1029,22 +1029,22 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
else
|
else
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "EXTEN")) {
|
} else if (c && !strcmp(var, "EXTEN")) {
|
||||||
strncpy(workspace, c->exten, workspacelen - 1);
|
ast_copy_string(workspace, c->exten, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "RDNIS")) {
|
} else if (c && !strcmp(var, "RDNIS")) {
|
||||||
if (c->cid.cid_rdnis) {
|
if (c->cid.cid_rdnis) {
|
||||||
strncpy(workspace, c->cid.cid_rdnis, workspacelen - 1);
|
ast_copy_string(workspace, c->cid.cid_rdnis, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else
|
} else
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
} else if (c && !strcmp(var, "CONTEXT")) {
|
} else if (c && !strcmp(var, "CONTEXT")) {
|
||||||
strncpy(workspace, c->context, workspacelen - 1);
|
ast_copy_string(workspace, c->context, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "PRIORITY")) {
|
} else if (c && !strcmp(var, "PRIORITY")) {
|
||||||
snprintf(workspace, workspacelen, "%d", c->priority);
|
snprintf(workspace, workspacelen, "%d", c->priority);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "CHANNEL")) {
|
} else if (c && !strcmp(var, "CHANNEL")) {
|
||||||
strncpy(workspace, c->name, workspacelen - 1);
|
ast_copy_string(workspace, c->name, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (!strcmp(var, "EPOCH")) {
|
} else if (!strcmp(var, "EPOCH")) {
|
||||||
snprintf(workspace, workspacelen, "%u",(int)time(NULL));
|
snprintf(workspace, workspacelen, "%u",(int)time(NULL));
|
||||||
@@ -1081,10 +1081,10 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
|
|||||||
snprintf(workspace, workspacelen, "%d", c->hangupcause);
|
snprintf(workspace, workspacelen, "%d", c->hangupcause);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "ACCOUNTCODE")) {
|
} else if (c && !strcmp(var, "ACCOUNTCODE")) {
|
||||||
strncpy(workspace, c->accountcode, workspacelen - 1);
|
ast_copy_string(workspace, c->accountcode, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else if (c && !strcmp(var, "LANGUAGE")) {
|
} else if (c && !strcmp(var, "LANGUAGE")) {
|
||||||
strncpy(workspace, c->language, workspacelen - 1);
|
ast_copy_string(workspace, c->language, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
} else {
|
} else {
|
||||||
icky:
|
icky:
|
||||||
@@ -1096,7 +1096,7 @@ icky:
|
|||||||
if (strcasecmp(ast_var_name(variables),var)==0) {
|
if (strcasecmp(ast_var_name(variables),var)==0) {
|
||||||
*ret=ast_var_value(variables);
|
*ret=ast_var_value(variables);
|
||||||
if (*ret) {
|
if (*ret) {
|
||||||
strncpy(workspace, *ret, workspacelen - 1);
|
ast_copy_string(workspace, *ret, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1112,7 +1112,7 @@ icky:
|
|||||||
if (strcasecmp(ast_var_name(variables),var)==0) {
|
if (strcasecmp(ast_var_name(variables),var)==0) {
|
||||||
*ret=ast_var_value(variables);
|
*ret=ast_var_value(variables);
|
||||||
if (*ret) {
|
if (*ret) {
|
||||||
strncpy(workspace, *ret, workspacelen - 1);
|
ast_copy_string(workspace, *ret, workspacelen);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1444,7 +1444,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, const ch
|
|||||||
|
|
||||||
/* Store variable name (and truncate) */
|
/* Store variable name (and truncate) */
|
||||||
memset(var, 0, sizeof(var));
|
memset(var, 0, sizeof(var));
|
||||||
strncpy(var, vars, sizeof(var) - 1);
|
ast_copy_string(var, vars, sizeof(var));
|
||||||
var[len] = '\0';
|
var[len] = '\0';
|
||||||
|
|
||||||
/* Substitute if necessary */
|
/* Substitute if necessary */
|
||||||
@@ -1508,7 +1508,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, const ch
|
|||||||
|
|
||||||
/* Store variable name (and truncate) */
|
/* Store variable name (and truncate) */
|
||||||
memset(var, 0, sizeof(var));
|
memset(var, 0, sizeof(var));
|
||||||
strncpy(var, vars, sizeof(var) - 1);
|
ast_copy_string(var, vars, sizeof(var));
|
||||||
var[len] = '\0';
|
var[len] = '\0';
|
||||||
|
|
||||||
/* Substitute if necessary */
|
/* Substitute if necessary */
|
||||||
@@ -1555,7 +1555,7 @@ static void pbx_substitute_variables(char *passdata, int datalen, struct ast_cha
|
|||||||
|
|
||||||
/* No variables or expressions in e->data, so why scan it? */
|
/* No variables or expressions in e->data, so why scan it? */
|
||||||
if (!strstr(e->data,"${") && !strstr(e->data,"$[") && !strstr(e->data,"$(")) {
|
if (!strstr(e->data,"${") && !strstr(e->data,"$[") && !strstr(e->data,"$(")) {
|
||||||
strncpy(passdata, e->data, datalen - 1);
|
ast_copy_string(passdata, e->data, datalen);
|
||||||
passdata[datalen-1] = '\0';
|
passdata[datalen-1] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1613,9 +1613,9 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
|
|||||||
ast_mutex_unlock(&conlock);
|
ast_mutex_unlock(&conlock);
|
||||||
if (app) {
|
if (app) {
|
||||||
if (c->context != context)
|
if (c->context != context)
|
||||||
strncpy(c->context, context, sizeof(c->context)-1);
|
ast_copy_string(c->context, context, sizeof(c->context));
|
||||||
if (c->exten != exten)
|
if (c->exten != exten)
|
||||||
strncpy(c->exten, exten, sizeof(c->exten)-1);
|
ast_copy_string(c->exten, exten, sizeof(c->exten));
|
||||||
c->priority = priority;
|
c->priority = priority;
|
||||||
pbx_substitute_variables(passdata, sizeof(passdata), c, e);
|
pbx_substitute_variables(passdata, sizeof(passdata), c, e);
|
||||||
if (option_debug) {
|
if (option_debug) {
|
||||||
@@ -1741,7 +1741,7 @@ static int ast_extension_state2(struct ast_exten *e)
|
|||||||
if (!e)
|
if (!e)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
strncpy(hint, ast_get_extension_app(e), sizeof(hint)-1);
|
ast_copy_string(hint, ast_get_extension_app(e), sizeof(hint));
|
||||||
|
|
||||||
cur = hint; /* On or more devices separated with a & character */
|
cur = hint; /* On or more devices separated with a & character */
|
||||||
do {
|
do {
|
||||||
@@ -1845,7 +1845,7 @@ int ast_device_state_changed(const char *fmt, ...)
|
|||||||
|
|
||||||
while (list) {
|
while (list) {
|
||||||
|
|
||||||
strncpy(hint, ast_get_extension_app(list->exten), sizeof(hint) - 1);
|
ast_copy_string(hint, ast_get_extension_app(list->exten), sizeof(hint));
|
||||||
cur = hint;
|
cur = hint;
|
||||||
do {
|
do {
|
||||||
rest = strchr(cur, '&');
|
rest = strchr(cur, '&');
|
||||||
@@ -2186,14 +2186,15 @@ int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_
|
|||||||
{
|
{
|
||||||
struct ast_exten *e;
|
struct ast_exten *e;
|
||||||
void *tmp;
|
void *tmp;
|
||||||
|
|
||||||
e = ast_hint_extension(c, context, exten);
|
e = ast_hint_extension(c, context, exten);
|
||||||
if (e) {
|
if (e) {
|
||||||
if (hint)
|
if (hint)
|
||||||
strncpy(hint, ast_get_extension_app(e), hintsize - 1);
|
ast_copy_string(hint, ast_get_extension_app(e), hintsize);
|
||||||
if (name) {
|
if (name) {
|
||||||
tmp = ast_get_extension_app_data(e);
|
tmp = ast_get_extension_app_data(e);
|
||||||
if (tmp)
|
if (tmp)
|
||||||
strncpy(name, (char *)tmp, namesize - 1);
|
ast_copy_string(name, (char *) tmp, namesize);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2277,12 +2278,12 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
/* If not successful fall back to 's' */
|
/* If not successful fall back to 's' */
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority);
|
ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority);
|
||||||
strncpy(c->exten, "s", sizeof(c->exten)-1);
|
ast_copy_string(c->exten, "s", sizeof(c->exten));
|
||||||
if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
|
if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
|
||||||
/* JK02: And finally back to default if everything else failed */
|
/* JK02: And finally back to default if everything else failed */
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority);
|
ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority);
|
||||||
strncpy(c->context, "default", sizeof(c->context)-1);
|
ast_copy_string(c->context, "default", sizeof(c->context));
|
||||||
}
|
}
|
||||||
c->priority = 1;
|
c->priority = 1;
|
||||||
}
|
}
|
||||||
@@ -2332,7 +2333,7 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((c->_softhangup == AST_SOFTHANGUP_TIMEOUT) && (ast_exists_extension(c,c->context,"T",1,c->cid.cid_num))) {
|
if ((c->_softhangup == AST_SOFTHANGUP_TIMEOUT) && (ast_exists_extension(c,c->context,"T",1,c->cid.cid_num))) {
|
||||||
strncpy(c->exten,"T",sizeof(c->exten) - 1);
|
ast_copy_string(c->exten, "T", sizeof(c->exten));
|
||||||
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
|
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
|
||||||
c->whentohangup = 0;
|
c->whentohangup = 0;
|
||||||
c->priority = 0;
|
c->priority = 0;
|
||||||
@@ -2351,7 +2352,7 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name);
|
||||||
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten);
|
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten);
|
||||||
strncpy(c->exten, "i", sizeof(c->exten)-1);
|
ast_copy_string(c->exten, "i", sizeof(c->exten));
|
||||||
c->priority = 1;
|
c->priority = 1;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n",
|
ast_log(LOG_WARNING, "Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n",
|
||||||
@@ -2388,7 +2389,7 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
}
|
}
|
||||||
if (ast_exists_extension(c, c->context, exten, 1, c->cid.cid_num)) {
|
if (ast_exists_extension(c, c->context, exten, 1, c->cid.cid_num)) {
|
||||||
/* Prepare the next cycle */
|
/* Prepare the next cycle */
|
||||||
strncpy(c->exten, exten, sizeof(c->exten)-1);
|
ast_copy_string(c->exten, exten, sizeof(c->exten));
|
||||||
c->priority = 1;
|
c->priority = 1;
|
||||||
} else {
|
} else {
|
||||||
/* No such extension */
|
/* No such extension */
|
||||||
@@ -2398,7 +2399,7 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "Invalid extension '%s' in context '%s' on %s\n", exten, c->context, c->name);
|
ast_verbose( VERBOSE_PREFIX_3 "Invalid extension '%s' in context '%s' on %s\n", exten, c->context, c->name);
|
||||||
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", exten);
|
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", exten);
|
||||||
strncpy(c->exten, "i", sizeof(c->exten)-1);
|
ast_copy_string(c->exten, "i", sizeof(c->exten));
|
||||||
c->priority = 1;
|
c->priority = 1;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Invalid extension '%s', but no rule 'i' in context '%s'\n", exten, c->context);
|
ast_log(LOG_WARNING, "Invalid extension '%s', but no rule 'i' in context '%s'\n", exten, c->context);
|
||||||
@@ -2409,7 +2410,7 @@ static int __ast_pbx_run(struct ast_channel *c)
|
|||||||
if (ast_exists_extension(c, c->context, "t", 1, c->cid.cid_num)) {
|
if (ast_exists_extension(c, c->context, "t", 1, c->cid.cid_num)) {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "Timeout on %s\n", c->name);
|
ast_verbose( VERBOSE_PREFIX_3 "Timeout on %s\n", c->name);
|
||||||
strncpy(c->exten, "t", sizeof(c->exten)-1);
|
ast_copy_string(c->exten, "t", sizeof(c->exten));
|
||||||
c->priority = 1;
|
c->priority = 1;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Timeout, but no rule 't' in context '%s'\n", c->context);
|
ast_log(LOG_WARNING, "Timeout, but no rule 't' in context '%s'\n", c->context);
|
||||||
@@ -3941,7 +3942,7 @@ int ast_build_timing(struct ast_timing *i, char *info_in)
|
|||||||
if (ast_strlen_zero(info_in))
|
if (ast_strlen_zero(info_in))
|
||||||
return 0;
|
return 0;
|
||||||
/* make a copy just in case we were passed a static string */
|
/* make a copy just in case we were passed a static string */
|
||||||
strncpy(info_save, info_in, sizeof(info_save));
|
ast_copy_string(info_save, info_in, sizeof(info_save));
|
||||||
info = info_save;
|
info = info_save;
|
||||||
/* Assume everything except time */
|
/* Assume everything except time */
|
||||||
i->monthmask = (1 << 12) - 1;
|
i->monthmask = (1 << 12) - 1;
|
||||||
@@ -4385,9 +4386,9 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (context && !ast_strlen_zero(context))
|
if (context && !ast_strlen_zero(context))
|
||||||
strncpy(chan->context, context, sizeof(chan->context) - 1);
|
ast_copy_string(chan->context, context, sizeof(chan->context));
|
||||||
if (exten && !ast_strlen_zero(exten))
|
if (exten && !ast_strlen_zero(exten))
|
||||||
strncpy(chan->exten, exten, sizeof(chan->exten) - 1);
|
ast_copy_string(chan->exten, exten, sizeof(chan->exten));
|
||||||
if (priority > -1) {
|
if (priority > -1) {
|
||||||
chan->priority = priority;
|
chan->priority = priority;
|
||||||
/* see flag description in channel.h for explanation */
|
/* see flag description in channel.h for explanation */
|
||||||
@@ -4769,9 +4770,9 @@ static void *async_wait(void *data)
|
|||||||
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
|
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
|
||||||
} else {
|
} else {
|
||||||
if (!ast_strlen_zero(as->context))
|
if (!ast_strlen_zero(as->context))
|
||||||
strncpy(chan->context, as->context, sizeof(chan->context) - 1);
|
ast_copy_string(chan->context, as->context, sizeof(chan->context));
|
||||||
if (!ast_strlen_zero(as->exten))
|
if (!ast_strlen_zero(as->exten))
|
||||||
strncpy(chan->exten, as->exten, sizeof(chan->exten) - 1);
|
ast_copy_string(chan->exten, as->exten, sizeof(chan->exten));
|
||||||
if (as->priority > 0)
|
if (as->priority > 0)
|
||||||
chan->priority = as->priority;
|
chan->priority = as->priority;
|
||||||
/* Run the PBX */
|
/* Run the PBX */
|
||||||
@@ -4911,10 +4912,10 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
|
|||||||
if (ast_exists_extension(chan, context, "failed", 1, NULL)) {
|
if (ast_exists_extension(chan, context, "failed", 1, NULL)) {
|
||||||
chan = ast_channel_alloc(0);
|
chan = ast_channel_alloc(0);
|
||||||
if(chan) {
|
if(chan) {
|
||||||
strncpy(chan->name, "OutgoingSpoolFailed", sizeof(chan->name) - 1);
|
ast_copy_string(chan->name, "OutgoingSpoolFailed", sizeof(chan->name));
|
||||||
if (context && !ast_strlen_zero(context))
|
if (context && !ast_strlen_zero(context))
|
||||||
strncpy(chan->context, context, sizeof(chan->context) - 1);
|
ast_copy_string(chan->context, context, sizeof(chan->context));
|
||||||
strncpy(chan->exten, "failed", sizeof(chan->exten) - 1);
|
ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
|
||||||
chan->priority = 1;
|
chan->priority = 1;
|
||||||
if (variable) {
|
if (variable) {
|
||||||
tmp = ast_strdupa(variable);
|
tmp = ast_strdupa(variable);
|
||||||
@@ -4945,8 +4946,8 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
|
|||||||
if (account)
|
if (account)
|
||||||
ast_cdr_setaccount(chan, account);
|
ast_cdr_setaccount(chan, account);
|
||||||
as->chan = chan;
|
as->chan = chan;
|
||||||
strncpy(as->context, context, sizeof(as->context) - 1);
|
ast_copy_string(as->context, context, sizeof(as->context));
|
||||||
strncpy(as->exten, exten, sizeof(as->exten) - 1);
|
ast_copy_string(as->exten, exten, sizeof(as->exten));
|
||||||
as->priority = priority;
|
as->priority = priority;
|
||||||
as->timeout = timeout;
|
as->timeout = timeout;
|
||||||
if (variable) {
|
if (variable) {
|
||||||
@@ -5037,7 +5038,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
|
|||||||
tmp = malloc(sizeof(struct app_tmp));
|
tmp = malloc(sizeof(struct app_tmp));
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
memset(tmp, 0, sizeof(struct app_tmp));
|
memset(tmp, 0, sizeof(struct app_tmp));
|
||||||
strncpy(tmp->app, app, sizeof(tmp->app) - 1);
|
ast_copy_string(tmp->app, app, sizeof(tmp->app));
|
||||||
if (appdata)
|
if (appdata)
|
||||||
ast_copy_string(tmp->data, appdata, sizeof(tmp->data));
|
ast_copy_string(tmp->data, appdata, sizeof(tmp->data));
|
||||||
tmp->chan = chan;
|
tmp->chan = chan;
|
||||||
@@ -5101,9 +5102,9 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
|
|||||||
if (account)
|
if (account)
|
||||||
ast_cdr_setaccount(chan, account);
|
ast_cdr_setaccount(chan, account);
|
||||||
as->chan = chan;
|
as->chan = chan;
|
||||||
strncpy(as->app, app, sizeof(as->app) - 1);
|
ast_copy_string(as->app, app, sizeof(as->app));
|
||||||
if (appdata)
|
if (appdata)
|
||||||
strncpy(as->appdata, appdata, sizeof(as->appdata) - 1);
|
ast_copy_string(as->appdata, appdata, sizeof(as->appdata));
|
||||||
as->timeout = timeout;
|
as->timeout = timeout;
|
||||||
if (variable) {
|
if (variable) {
|
||||||
vartmp = ast_strdupa(variable);
|
vartmp = ast_strdupa(variable);
|
||||||
@@ -5290,7 +5291,7 @@ static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
/* Copy the language as specified */
|
/* Copy the language as specified */
|
||||||
if (data)
|
if (data)
|
||||||
strncpy(chan->language, (char *)data, sizeof(chan->language)-1);
|
ast_copy_string(chan->language, (char *) data, sizeof(chan->language));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -5347,9 +5348,9 @@ static int pbx_builtin_stripmsd(struct ast_channel *chan, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (strlen(chan->exten) > atoi(data)) {
|
if (strlen(chan->exten) > atoi(data)) {
|
||||||
strncpy(newexten, chan->exten + atoi(data), sizeof(newexten)-1);
|
ast_copy_string(newexten, chan->exten + atoi(data), sizeof(newexten));
|
||||||
}
|
}
|
||||||
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
|
ast_copy_string(chan->exten, newexten, sizeof(chan->exten));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5362,7 +5363,7 @@ static int pbx_builtin_prefix(struct ast_channel *chan, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
snprintf(newexten, sizeof(newexten), "%s%s", (char *)data, chan->exten);
|
snprintf(newexten, sizeof(newexten), "%s%s", (char *)data, chan->exten);
|
||||||
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
|
ast_copy_string(chan->exten, newexten, sizeof(chan->exten));
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Prepended prefix, new extension is %s\n", chan->exten);
|
ast_verbose(VERBOSE_PREFIX_3 "Prepended prefix, new extension is %s\n", chan->exten);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -5377,7 +5378,7 @@ static int pbx_builtin_suffix(struct ast_channel *chan, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
snprintf(newexten, sizeof(newexten), "%s%s", chan->exten, (char *)data);
|
snprintf(newexten, sizeof(newexten), "%s%s", chan->exten, (char *)data);
|
||||||
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
|
ast_copy_string(chan->exten, newexten, sizeof(chan->exten));
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Appended suffix, new extension is %s\n", chan->exten);
|
ast_verbose(VERBOSE_PREFIX_3 "Appended suffix, new extension is %s\n", chan->exten);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -5514,7 +5515,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
|
|||||||
} else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
|
} else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name);
|
||||||
strncpy(chan->exten, "t", sizeof(chan->exten));
|
ast_copy_string(chan->exten, "t", sizeof(chan->exten));
|
||||||
chan->priority = 0;
|
chan->priority = 0;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
|
ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
|
||||||
@@ -5916,7 +5917,7 @@ static int pbx_builtin_saynumber(struct ast_channel *chan, void *data)
|
|||||||
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
|
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tmp, (char *)data, sizeof(tmp)-1);
|
ast_copy_string(tmp, (char *) data, sizeof(tmp));
|
||||||
number=tmp;
|
number=tmp;
|
||||||
strsep(&number, "|");
|
strsep(&number, "|");
|
||||||
options = strsep(&number, "|");
|
options = strsep(&number, "|");
|
||||||
|
Reference in New Issue
Block a user