aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_local.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 17:53:39 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 17:53:39 +0000
commita64824fdc0d57f5e511e8c7108a56fe146b8f1da (patch)
tree2629cf27e4b993bbe765edd889afe5256b02a4bc /channels/chan_local.c
parent3cec63b876c1892f2d672f14d0da13e179f995e0 (diff)
replace strncpy with ast_copy_string.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@22016 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r--channels/chan_local.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 5705dc905..f4e0e2b14 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -427,7 +427,7 @@ static int local_hangup(struct ast_channel *ast)
}
/*! \brief Create a call structure */
-static struct local_pvt *local_alloc(char *data, int format)
+static struct local_pvt *local_alloc(const char *data, int format)
{
struct local_pvt *tmp;
char *c;
@@ -437,21 +437,17 @@ static struct local_pvt *local_alloc(char *data, int format)
return NULL;
ast_mutex_init(&tmp->lock);
- strncpy(tmp->exten, data, sizeof(tmp->exten) - 1);
+ ast_copy_string(tmp->exten, data, sizeof(tmp->exten));
opts = strchr(tmp->exten, '/');
if (opts) {
- *opts='\0';
- opts++;
+ *opts++ = '\0';
if (strchr(opts, 'n'))
tmp->nooptimization = 1;
}
c = strchr(tmp->exten, '@');
- if (c) {
- *c = '\0';
- c++;
- strncpy(tmp->context, c, sizeof(tmp->context) - 1);
- } else
- strncpy(tmp->context, "default", sizeof(tmp->context) - 1);
+ if (c)
+ *c++ = '\0';
+ ast_copy_string(tmp->context, c ? c : "default", sizeof(tmp->context));
tmp->reqformat = format;
if (!ast_exists_extension(NULL, tmp->context, tmp->exten, 1, NULL)) {
ast_log(LOG_NOTICE, "No such extension/context %s@%s creating local channel\n", tmp->exten, tmp->context);