aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_mgcp.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
commit000e0986072e528276eb7ea9a37728b5b0e6be76 (patch)
treeb186c37b5085861c464a92debbf99dd8c2b71780 /channels/chan_mgcp.c
parentc3ad9c9ef53aa9d4297f7c0f009da3c33f50bebc (diff)
apparently developers are still not aware that they should be use ast_copy_string instead of strncpy... fix up many more users, and fix some bugs in the process
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46200 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_mgcp.c')
-rw-r--r--channels/chan_mgcp.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index d53433ab6..778fd4ca7 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -3651,7 +3651,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
} else if (!strcasecmp(v->name, "port")) {
gw->addr.sin_port = htons(atoi(v->value));
} else if (!strcasecmp(v->name, "context")) {
- strncpy(context, v->value, sizeof(context) - 1);
+ ast_copy_string(context, v->value, sizeof(context));
} else if (!strcasecmp(v->name, "dtmfmode")) {
if (!strcasecmp(v->value, "inband"))
dtmfmode = MGCP_DTMF_INBAND;
@@ -3673,9 +3673,9 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
}
} else if (!strcasecmp(v->name, "language")) {
- strncpy(language, v->value, sizeof(language)-1);
+ ast_copy_string(language, v->value, sizeof(language));
} else if (!strcasecmp(v->name, "accountcode")) {
- strncpy(accountcode, v->value, sizeof(accountcode)-1);
+ ast_copy_string(accountcode, v->value, sizeof(accountcode));
} else if (!strcasecmp(v->name, "amaflags")) {
y = ast_cdr_amaflags2int(v->value);
if (y < 0) {
@@ -3684,7 +3684,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
amaflags = y;
}
} else if (!strcasecmp(v->name, "musiconhold")) {
- strncpy(musicclass, v->value, sizeof(musicclass)-1);
+ ast_copy_string(musicclass, v->value, sizeof(musicclass));
} else if (!strcasecmp(v->name, "callgroup")) {
cur_callergroup = ast_get_group(v->value);
} else if (!strcasecmp(v->name, "pickupgroup")) {
@@ -3698,7 +3698,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
} else if (!strcasecmp(v->name, "canreinvite")) {
canreinvite = ast_true(v->value);
} else if (!strcasecmp(v->name, "mailbox")) {
- strncpy(mailbox, v->value, sizeof(mailbox) -1);
+ ast_copy_string(mailbox, v->value, sizeof(mailbox));
} else if (!strcasecmp(v->name, "adsi")) {
adsi = ast_true(v->value);
} else if (!strcasecmp(v->name, "callreturn")) {
@@ -3736,19 +3736,18 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_queue_lock);
- strncpy(e->name, v->value, sizeof(e->name) - 1);
+ ast_copy_string(e->name, v->value, sizeof(e->name));
e->needaudit = 1;
}
- strncpy(gw->wcardep, v->value, sizeof(gw->wcardep) - 1);
- /*strncpy(e->name, "aaln/" "*", sizeof(e->name) - 1);*/
+ ast_copy_string(gw->wcardep, v->value, sizeof(gw->wcardep));
/* XXX Should we really check for uniqueness?? XXX */
- strncpy(e->accountcode, accountcode, sizeof(e->accountcode) - 1);
- strncpy(e->context, context, sizeof(e->context) - 1);
- strncpy(e->cid_num, cid_num, sizeof(e->cid_num) - 1);
- strncpy(e->cid_name, cid_name, sizeof(e->cid_name) - 1);
- strncpy(e->language, language, sizeof(e->language) - 1);
- strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1);
- strncpy(e->mailbox, mailbox, sizeof(e->mailbox) - 1);
+ ast_copy_string(e->accountcode, accountcode, sizeof(e->accountcode));
+ ast_copy_string(e->context, context, sizeof(e->context));
+ ast_copy_string(e->cid_num, cid_num, sizeof(e->cid_num));
+ ast_copy_string(e->cid_name, cid_name, sizeof(e->cid_name));
+ ast_copy_string(e->language, language, sizeof(e->language));
+ ast_copy_string(e->musicclass, musicclass, sizeof(e->musicclass));
+ ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random());
e->msgstate = -1;
e->amaflags = amaflags;
@@ -3836,17 +3835,17 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_queue_lock);
- strncpy(e->name, v->value, sizeof(e->name) - 1);
+ ast_copy_string(e->name, v->value, sizeof(e->name));
e->needaudit = 1;
}
/* XXX Should we really check for uniqueness?? XXX */
- strncpy(e->accountcode, accountcode, sizeof(e->accountcode) - 1);
- strncpy(e->context, context, sizeof(e->context) - 1);
- strncpy(e->cid_num, cid_num, sizeof(e->cid_num) - 1);
- strncpy(e->cid_name, cid_name, sizeof(e->cid_name) - 1);
- strncpy(e->language, language, sizeof(e->language) - 1);
- strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1);
- strncpy(e->mailbox, mailbox, sizeof(e->mailbox)-1);
+ ast_copy_string(e->accountcode, accountcode, sizeof(e->accountcode));
+ ast_copy_string(e->context, context, sizeof(e->context));
+ ast_copy_string(e->cid_num, cid_num, sizeof(e->cid_num));
+ ast_copy_string(e->cid_name, cid_name, sizeof(e->cid_name));
+ ast_copy_string(e->language, language, sizeof(e->language));
+ ast_copy_string(e->musicclass, musicclass, sizeof(e->musicclass));
+ ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
if (!ast_strlen_zero(mailbox)) {
ast_verbose(VERBOSE_PREFIX_3 "Setting mailbox '%s' on %s@%s\n", mailbox, gw->name, e->name);
}
@@ -3899,7 +3898,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
memset(sub, 0, sizeof(struct mgcp_subchannel));
ast_mutex_init(&sub->lock);
ast_mutex_init(&sub->cx_queue_lock);
- strncpy(sub->magic, MGCP_SUBCHANNEL_MAGIC, sizeof(sub->magic) - 1);
+ ast_copy_string(sub->magic, MGCP_SUBCHANNEL_MAGIC, sizeof(sub->magic));
sub->parent = e;
sub->id = i;
snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random());