Merged revisions 46200 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r46200 | kpfleming | 2006-10-25 09:32:08 -0500 (Wed, 25 Oct 2006) | 2 lines

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: https://origsvn.digium.com/svn/asterisk/trunk@46201 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Kevin P. Fleming 19 years ago
parent c30f1d12c5
commit 749029de38

@ -71,21 +71,20 @@ static int cpeid_exec(struct ast_channel *chan, void *idata)
int gotgeometry = 0; int gotgeometry = 0;
int gotcpeid = 0; int gotcpeid = 0;
int width, height, buttons; int width, height, buttons;
char data[4][80]; char *data[4];
char *stuff[4]; unsigned int x;
u = ast_module_user_add(chan); u = ast_module_user_add(chan);
stuff[0] = data[0];
stuff[1] = data[1]; for (x = 0; x < 4; x++)
stuff[2] = data[2]; data[x] = alloca(80);
stuff[3] = data[3];
memset(data, 0, sizeof(data)); strcpy(data[0], "** CPE Info **");
strncpy(stuff[0], "** CPE Info **", sizeof(data[0]) - 1); strcpy(data[1], "Identifying CPE...");
strncpy(stuff[1], "Identifying CPE...", sizeof(data[1]) - 1); strcpy(data[2], "Please wait...");
strncpy(stuff[2], "Please wait...", sizeof(data[2]) - 1);
res = ast_adsi_load_session(chan, NULL, 0, 1); res = ast_adsi_load_session(chan, NULL, 0, 1);
if (res > 0) { if (res > 0) {
cpeid_setstatus(chan, stuff, 0); cpeid_setstatus(chan, data, 0);
res = ast_adsi_get_cpeid(chan, cpeid, 0); res = ast_adsi_get_cpeid(chan, cpeid, 0);
if (res > 0) { if (res > 0) {
gotcpeid = 1; gotcpeid = 1;
@ -93,9 +92,9 @@ static int cpeid_exec(struct ast_channel *chan, void *idata)
ast_verbose(VERBOSE_PREFIX_3 "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name); ast_verbose(VERBOSE_PREFIX_3 "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name);
} }
if (res > -1) { if (res > -1) {
strncpy(stuff[1], "Measuring CPE...", sizeof(data[1]) - 1); strcpy(data[1], "Measuring CPE...");
strncpy(stuff[2], "Please wait...", sizeof(data[2]) - 1); strcpy(data[2], "Please wait...");
cpeid_setstatus(chan, stuff, 0); cpeid_setstatus(chan, data, 0);
res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0); res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
if (res > -1) { if (res > -1) {
if (option_verbose > 2) if (option_verbose > 2)
@ -105,15 +104,15 @@ static int cpeid_exec(struct ast_channel *chan, void *idata)
} }
if (res > -1) { if (res > -1) {
if (gotcpeid) if (gotcpeid)
snprintf(stuff[1], sizeof(data[1]), "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]); snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]);
else else
strncpy(stuff[1], "CPEID Unknown", sizeof(data[1]) - 1); strcpy(data[1], "CPEID Unknown");
if (gotgeometry) if (gotgeometry)
snprintf(stuff[2], sizeof(data[2]), "Geom: %dx%d, %d buttons", width, height, buttons); snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons);
else else
strncpy(stuff[2], "Geometry unknown", sizeof(data[2]) - 1); strcpy(data[2], "Geometry unknown");
strncpy(stuff[3], "Press # to exit", sizeof(data[3]) - 1); strcpy(data[3], "Press # to exit");
cpeid_setstatus(chan, stuff, 1); cpeid_setstatus(chan, data, 1);
for(;;) { for(;;) {
res = ast_waitfordigit(chan, 1000); res = ast_waitfordigit(chan, 1000);
if (res < 0) if (res < 0)

@ -141,7 +141,7 @@ static int ices_exec(struct ast_channel *chan, void *data)
return -1; return -1;
} }
if (((char *)data)[0] == '/') if (((char *)data)[0] == '/')
strncpy(filename, (char *)data, sizeof(filename) - 1); ast_copy_string(filename, (char *) data, sizeof(filename));
else else
snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, (char *)data); snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, (char *)data);
/* Placeholder for options */ /* Placeholder for options */

@ -78,13 +78,13 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
{ {
int res=0; int res=0;
char *return_context; char *return_context;
int l, lot, timeout = 0, dres; int lot, timeout = 0, dres;
char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr; char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr;
char *template, *tpl_working, *tpl_current; char *template, *tpl_working, *tpl_current;
char *tmp[100]; char *tmp[100];
char buf[13]; char buf[13];
int looptemp=0,i=0; int looptemp=0,i=0;
char *s,*orig_s; char *s;
struct ast_channel *dchan; struct ast_channel *dchan;
struct outgoing_helper oh; struct outgoing_helper oh;
@ -99,18 +99,11 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
u = ast_module_user_add(chan); u = ast_module_user_add(chan);
l=strlen(data)+2; s = ast_strdupa(data);
if (!(orig_s = ast_malloc(l))) {
ast_module_user_remove(u);
return -1;
}
s=orig_s;
strncpy(s,data,l);
template=strsep(&s,"|"); template=strsep(&s,"|");
if(! template) { if(! template) {
ast_log(LOG_WARNING, "PARK: An announce template must be defined\n"); ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} }
@ -122,7 +115,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
dial=strsep(&s, "|"); dial=strsep(&s, "|");
if(!dial) { if(!dial) {
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n"); ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n");
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} else { } else {
@ -155,16 +147,15 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
} }
if(atoi(priority) < 0) { if(atoi(priority) < 0) {
ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority); ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} }
/* At this point we have a priority and maybe an extension and a context */ /* At this point we have a priority and maybe an extension and a context */
chan->priority = atoi(priority); chan->priority = atoi(priority);
if (exten) if (exten)
strncpy(chan->exten, exten, sizeof(chan->exten)-1); ast_copy_string(chan->exten, exten, sizeof(chan->exten));
if (context) if (context)
strncpy(chan->context, context, sizeof(chan->context)-1); ast_copy_string(chan->context, context, sizeof(chan->context));
} else { /* increment the priority by default*/ } else { /* increment the priority by default*/
chan->priority++; chan->priority++;
} }
@ -202,13 +193,11 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name); ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name);
ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name); ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
ast_hangup(dchan); ast_hangup(dchan);
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} }
} else { } else {
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n"); ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} }
@ -245,7 +234,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
ast_stopstream(dchan); ast_stopstream(dchan);
ast_hangup(dchan); ast_hangup(dchan);
free(orig_s);
ast_module_user_remove(u); ast_module_user_remove(u);

@ -767,10 +767,6 @@ static void clear_and_free_interfaces(void)
extra fields in the tables. */ extra fields in the tables. */
static void queue_set_param(struct call_queue *q, const char *param, const char *val, int linenum, int failunknown) static void queue_set_param(struct call_queue *q, const char *param, const char *val, int linenum, int failunknown)
{ {
int i = 0;
char *c, *lastc;
char buff[80];
if (!strcasecmp(param, "musicclass") || if (!strcasecmp(param, "musicclass") ||
!strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) { !strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) {
ast_copy_string(q->moh, val, sizeof(q->moh)); ast_copy_string(q->moh, val, sizeof(q->moh));
@ -831,22 +827,18 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
else else
q->announceholdtime = 0; q->announceholdtime = 0;
} else if (!strcasecmp(param, "periodic-announce")) { } else if (!strcasecmp(param, "periodic-announce")) {
if (strchr(val,'|')) { if (strchr(val, '|')) {
lastc = (char *)val; char *s, *buf = ast_strdupa(val);
while ((c = strchr(lastc,'|'))) { unsigned int i = 0;
if (i > MAX_PERIODIC_ANNOUNCEMENTS)
break; while ((s = strsep(&buf, "|"))) {
strncpy(buff, lastc, abs(lastc - c)); ast_copy_string(q->sound_periodicannounce[i], s, sizeof(q->sound_periodicannounce[i]));
buff[abs(lastc - c)] = '\0';
ast_copy_string(q->sound_periodicannounce[i], buff, sizeof(q->sound_periodicannounce[i]));
lastc = (c + 1);
i++; i++;
} if (i == MAX_PERIODIC_ANNOUNCEMENTS)
if (strlen(lastc)) { break;
ast_copy_string(q->sound_periodicannounce[i], lastc, sizeof(q->sound_periodicannounce[i]));
} }
} else { } else {
ast_copy_string(q->sound_periodicannounce[i], val, sizeof(q->sound_periodicannounce[i])); ast_copy_string(q->sound_periodicannounce[0], val, sizeof(q->sound_periodicannounce[0]));
} }
} else if (!strcasecmp(param, "periodic-announce-frequency")) { } else if (!strcasecmp(param, "periodic-announce-frequency")) {
q->periodicannouncefrequency = atoi(val); q->periodicannouncefrequency = atoi(val);

@ -212,7 +212,7 @@ static int record_exec(struct ast_channel *chan, void *data)
} while (ast_fileexists(tmp, ext, chan->language) > 0); } while (ast_fileexists(tmp, ext, chan->language) > 0);
pbx_builtin_setvar_helper(chan, "RECORDED_FILE", tmp); pbx_builtin_setvar_helper(chan, "RECORDED_FILE", tmp);
} else } else
strncpy(tmp, filename, sizeof(tmp)-1); ast_copy_string(tmp, filename, sizeof(tmp));
/* end of routine mentioned */ /* end of routine mentioned */

@ -1389,7 +1389,7 @@ static int sms_exec (struct ast_channel *chan, void *data)
ast_module_user_remove(u); ast_module_user_remove(u);
return -1; return -1;
} }
strncpy (h.queue, (char *)d, p - d); strncpy(h.queue, (char *)d, p - d);
if (*p == '|') if (*p == '|')
p++; p++;
d = p; d = p;

@ -74,7 +74,7 @@ static int softhangup_exec(struct ast_channel *chan, void *data)
all = options && strchr(options,'a'); all = options && strchr(options,'a');
c = ast_channel_walk_locked(NULL); c = ast_channel_walk_locked(NULL);
while (c) { while (c) {
strncpy(name, c->name, sizeof(name)-1); ast_copy_string(name, c->name, sizeof(name));
ast_mutex_unlock(&c->lock); ast_mutex_unlock(&c->lock);
/* XXX watch out, i think it is wrong to access c-> after unlocking! */ /* XXX watch out, i think it is wrong to access c-> after unlocking! */
if (all) { if (all) {

@ -7278,23 +7278,22 @@ static int load_config(void)
char *tmpread, *tmpwrite; char *tmpread, *tmpwrite;
emailbody = ast_strdup(s); emailbody = ast_strdup(s);
/* substitute strings \t and \n into the apropriate characters */ /* substitute strings \t and \n into the appropriate characters */
tmpread = tmpwrite = emailbody; tmpread = tmpwrite = emailbody;
while ((tmpwrite = strchr(tmpread,'\\'))) { while ((tmpwrite = strchr(tmpread,'\\'))) {
int len = strlen("\n");
switch (tmpwrite[1]) { switch (tmpwrite[1]) {
case 'n': case 'n':
strncpy(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); *tmpwrite++ = '\n';
strncpy(tmpwrite, "\n", len); memmove(tmpwrite, tmpwrite + 1, strlen(tmpwrite + 1) + 1);
break; break;
case 't': case 't':
strncpy(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); *tmpwrite++ = '\t';
strncpy(tmpwrite, "\t", len); memmove(tmpwrite, tmpwrite + 1, strlen(tmpwrite + 1) + 1);
break; break;
default: default:
ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]); ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]);
} }
tmpread = tmpwrite + len; tmpread = tmpwrite + 1;
} }
} }
if ((s = ast_variable_retrieve(cfg, "general", "pagersubject"))) if ((s = ast_variable_retrieve(cfg, "general", "pagersubject")))
@ -7303,23 +7302,22 @@ static int load_config(void)
char *tmpread, *tmpwrite; char *tmpread, *tmpwrite;
pagerbody = ast_strdup(s); pagerbody = ast_strdup(s);
/* substitute strings \t and \n into the apropriate characters */ /* substitute strings \t and \n into the appropriate characters */
tmpread = tmpwrite = pagerbody; tmpread = tmpwrite = pagerbody;
while ((tmpwrite = strchr(tmpread, '\\'))) { while ((tmpwrite = strchr(tmpread, '\\'))) {
int len = strlen("\n");
switch (tmpwrite[1]) { switch (tmpwrite[1]) {
case 'n': case 'n':
strncpy(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); *tmpwrite++ = '\n';
strncpy(tmpwrite, "\n", len); memmove(tmpwrite, tmpwrite + 1, strlen(tmpwrite + 1) + 1);
break; break;
case 't': case 't':
strncpy(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); *tmpwrite++ = '\t';
strncpy(tmpwrite, "\t", len); memmove(tmpwrite, tmpwrite + 1, strlen(tmpwrite + 1) + 1);
break; break;
default: default:
ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]); ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]);
} }
tmpread = tmpwrite + len; tmpread = tmpwrite + 1;
} }
} }
AST_LIST_UNLOCK(&users); AST_LIST_UNLOCK(&users);

@ -77,9 +77,9 @@ static int load_config(int reload)
while(var) { while(var) {
ast_mutex_lock(&lock); ast_mutex_lock(&lock);
if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) { if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) {
if (strlen(var->value) > (sizeof(format) - 2)) if (strlen(var->value) > (sizeof(format) - 1))
ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno); ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
strncpy(format, var->value, sizeof(format) - 2); ast_copy_string(format, var->value, sizeof(format) - 1);
strcat(format,"\n"); strcat(format,"\n");
snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name); snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
ast_mutex_unlock(&lock); ast_mutex_unlock(&lock);

@ -1042,7 +1042,7 @@ static int console_dial(int fd, int argc, char *argv[])
myc = context; myc = context;
if (argc == 3) { if (argc == 3) {
char *stringp = NULL; char *stringp = NULL;
strncpy(tmp, argv[2], sizeof(tmp) - 1); ast_copy_string(tmp, argv[2], sizeof(tmp));
stringp = tmp; stringp = tmp;
strsep(&stringp, "@"); strsep(&stringp, "@");
tmp2 = strsep(&stringp, "@"); tmp2 = strsep(&stringp, "@");
@ -1052,8 +1052,8 @@ static int console_dial(int fd, int argc, char *argv[])
myc = tmp2; myc = tmp2;
} }
if (ast_exists_extension(NULL, myc, mye, 1, NULL)) { if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
strncpy(alsa.exten, mye, sizeof(alsa.exten) - 1); ast_copy_string(alsa.exten, mye, sizeof(alsa.exten));
strncpy(alsa.context, myc, sizeof(alsa.context) - 1); ast_copy_string(alsa.context, myc, sizeof(alsa.context));
hookstate = 1; hookstate = 1;
alsa_new(&alsa, AST_STATE_RINGING); alsa_new(&alsa, AST_STATE_RINGING);
} else } else

@ -437,8 +437,8 @@ static struct feature_pvt *features_alloc(char *data, int format)
for (x=0;x<3;x++) for (x=0;x<3;x++)
init_sub(tmp->subs + x); init_sub(tmp->subs + x);
ast_mutex_init(&tmp->lock); ast_mutex_init(&tmp->lock);
strncpy(tmp->tech, tech, sizeof(tmp->tech) - 1); ast_copy_string(tmp->tech, tech, sizeof(tmp->tech));
strncpy(tmp->dest, dest, sizeof(tmp->dest) - 1); ast_copy_string(tmp->dest, dest, sizeof(tmp->dest));
tmp->subchan = chan; tmp->subchan = chan;
AST_LIST_LOCK(&features); AST_LIST_LOCK(&features);
AST_LIST_INSERT_HEAD(&features, tmp, list); AST_LIST_INSERT_HEAD(&features, tmp, list);

@ -604,7 +604,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
ast_mutex_lock(&pvt->lock); ast_mutex_lock(&pvt->lock);
if (!gatekeeper_disable) { if (!gatekeeper_disable) {
if (ast_strlen_zero(pvt->exten)) { if (ast_strlen_zero(pvt->exten)) {
strncpy(called_addr, dest, sizeof(called_addr)); ast_copy_string(called_addr, dest, sizeof(called_addr));
} else { } else {
snprintf(called_addr, sizeof(called_addr), "%s@%s", pvt->exten, dest); snprintf(called_addr, sizeof(called_addr), "%s@%s", pvt->exten, dest);
} }
@ -621,13 +621,13 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
called_addr[sizeof(called_addr) - 1] = '\0'; called_addr[sizeof(called_addr) - 1] = '\0';
if (c->cid.cid_num) if (c->cid.cid_num)
strncpy(pvt->options.cid_num, c->cid.cid_num, sizeof(pvt->options.cid_num)); ast_copy_string(pvt->options.cid_num, c->cid.cid_num, sizeof(pvt->options.cid_num));
if (c->cid.cid_name) if (c->cid.cid_name)
strncpy(pvt->options.cid_name, c->cid.cid_name, sizeof(pvt->options.cid_name)); ast_copy_string(pvt->options.cid_name, c->cid.cid_name, sizeof(pvt->options.cid_name));
if (c->cid.cid_rdnis) { if (c->cid.cid_rdnis) {
strncpy(pvt->options.cid_rdnis, c->cid.cid_rdnis, sizeof(pvt->options.cid_rdnis)); ast_copy_string(pvt->options.cid_rdnis, c->cid.cid_rdnis, sizeof(pvt->options.cid_rdnis));
} }
pvt->options.presentation = c->cid.cid_pres; pvt->options.presentation = c->cid.cid_pres;
@ -1054,8 +1054,8 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
/* Set the owner of this channel */ /* Set the owner of this channel */
pvt->owner = ch; pvt->owner = ch;
strncpy(ch->context, pvt->context, sizeof(ch->context) - 1); ast_copy_string(ch->context, pvt->context, sizeof(ch->context));
strncpy(ch->exten, pvt->exten, sizeof(ch->exten) - 1); ast_copy_string(ch->exten, pvt->exten, sizeof(ch->exten));
ch->priority = 1; ch->priority = 1;
if (!ast_strlen_zero(pvt->accountcode)) { if (!ast_strlen_zero(pvt->accountcode)) {
ast_string_field_set(ch, accountcode, pvt->accountcode); ast_string_field_set(ch, accountcode, pvt->accountcode);
@ -1136,7 +1136,7 @@ static struct oh323_pvt *oh323_alloc(int callid)
} else { } else {
pvt->nonCodecCapability &= ~AST_RTP_DTMF; pvt->nonCodecCapability &= ~AST_RTP_DTMF;
} }
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, default_context, sizeof(pvt->context));
pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->update_rtp_info = pvt->DTMFsched = -1; pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->update_rtp_info = pvt->DTMFsched = -1;
ast_mutex_init(&pvt->lock); ast_mutex_init(&pvt->lock);
/* Add to interface list */ /* Add to interface list */
@ -1209,16 +1209,16 @@ static struct oh323_alias *build_alias(const char *name, struct ast_variable *v,
ASTOBJ_INIT(alias); ASTOBJ_INIT(alias);
} }
if (!found && name) if (!found && name)
strncpy(alias->name, name, sizeof(alias->name) - 1); ast_copy_string(alias->name, name, sizeof(alias->name));
for (; v || ((v = alt) && !(alt = NULL)); v = v->next) { for (; v || ((v = alt) && !(alt = NULL)); v = v->next) {
if (!strcasecmp(v->name, "e164")) { if (!strcasecmp(v->name, "e164")) {
strncpy(alias->e164, v->value, sizeof(alias->e164) - 1); ast_copy_string(alias->e164, v->value, sizeof(alias->e164));
} else if (!strcasecmp(v->name, "prefix")) { } else if (!strcasecmp(v->name, "prefix")) {
strncpy(alias->prefix, v->value, sizeof(alias->prefix) - 1); ast_copy_string(alias->prefix, v->value, sizeof(alias->prefix));
} else if (!strcasecmp(v->name, "context")) { } else if (!strcasecmp(v->name, "context")) {
strncpy(alias->context, v->value, sizeof(alias->context) - 1); ast_copy_string(alias->context, v->value, sizeof(alias->context));
} else if (!strcasecmp(v->name, "secret")) { } else if (!strcasecmp(v->name, "secret")) {
strncpy(alias->secret, v->value, sizeof(alias->secret) - 1); ast_copy_string(alias->secret, v->value, sizeof(alias->secret));
} else { } else {
if (strcasecmp(v->value, "h323")) { if (strcasecmp(v->value, "h323")) {
ast_log(LOG_WARNING, "Keyword %s does not make sense in type=h323\n", v->name); ast_log(LOG_WARNING, "Keyword %s does not make sense in type=h323\n", v->name);
@ -1383,9 +1383,9 @@ static struct oh323_user *build_user(char *name, struct ast_variable *v, struct
user->options.dtmfmode = 0; user->options.dtmfmode = 0;
user->options.holdHandling = 0; user->options.holdHandling = 0;
/* Set default context */ /* Set default context */
strncpy(user->context, default_context, sizeof(user->context) - 1); ast_copy_string(user->context, default_context, sizeof(user->context));
if (user && !found) if (user && !found)
strncpy(user->name, name, sizeof(user->name) - 1); ast_copy_string(user->name, name, sizeof(user->name));
#if 0 /* XXX Port channel variables functionality from chan_sip XXX */ #if 0 /* XXX Port channel variables functionality from chan_sip XXX */
if (user->chanvars) { if (user->chanvars) {
@ -1398,11 +1398,11 @@ static struct oh323_user *build_user(char *name, struct ast_variable *v, struct
if (!update_common_options(v, &user->options)) if (!update_common_options(v, &user->options))
continue; continue;
if (!strcasecmp(v->name, "context")) { if (!strcasecmp(v->name, "context")) {
strncpy(user->context, v->value, sizeof(user->context) - 1); ast_copy_string(user->context, v->value, sizeof(user->context));
} else if (!strcasecmp(v->name, "secret")) { } else if (!strcasecmp(v->name, "secret")) {
strncpy(user->secret, v->value, sizeof(user->secret) - 1); ast_copy_string(user->secret, v->value, sizeof(user->secret));
} else if (!strcasecmp(v->name, "accountcode")) { } else if (!strcasecmp(v->name, "accountcode")) {
strncpy(user->accountcode, v->value, sizeof(user->accountcode) - 1); ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
} else if (!strcasecmp(v->name, "host")) { } else if (!strcasecmp(v->name, "host")) {
if (!strcasecmp(v->value, "dynamic")) { if (!strcasecmp(v->value, "dynamic")) {
ast_log(LOG_ERROR, "A dynamic host on a type=user does not make any sense\n"); ast_log(LOG_ERROR, "A dynamic host on a type=user does not make any sense\n");
@ -1498,7 +1498,7 @@ static struct oh323_peer *build_peer(const char *name, struct ast_variable *v, s
peer->addr.sin_port = htons(h323_signalling_port); peer->addr.sin_port = htons(h323_signalling_port);
peer->addr.sin_family = AF_INET; peer->addr.sin_family = AF_INET;
if (!found && name) if (!found && name)
strncpy(peer->name, name, sizeof(peer->name) - 1); ast_copy_string(peer->name, name, sizeof(peer->name));
#if 0 /* XXX Port channel variables functionality from chan_sip XXX */ #if 0 /* XXX Port channel variables functionality from chan_sip XXX */
if (peer->chanvars) { if (peer->chanvars) {
@ -1650,7 +1650,7 @@ static int create_addr(struct oh323_pvt *pvt, char *opeer)
char *hostn; char *hostn;
char peer[256] = ""; char peer[256] = "";
strncpy(peer, opeer, sizeof(peer) - 1); ast_copy_string(peer, opeer, sizeof(peer));
port = strchr(peer, ':'); port = strchr(peer, ':');
if (port) { if (port) {
*port = '\0'; *port = '\0';
@ -1738,7 +1738,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
*cause = AST_CAUSE_INCOMPATIBLE_DESTINATION; *cause = AST_CAUSE_INCOMPATIBLE_DESTINATION;
return NULL; return NULL;
} }
strncpy(tmp, dest, sizeof(tmp) - 1); ast_copy_string(tmp, dest, sizeof(tmp));
host = strchr(tmp, '@'); host = strchr(tmp, '@');
if (host) { if (host) {
*host = '\0'; *host = '\0';
@ -1755,7 +1755,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
h323_set_id(h323id); h323_set_id(h323id);
} }
if (ext) { if (ext) {
strncpy(pvt->exten, ext, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, ext, sizeof(pvt->exten));
} }
if (h323debug) if (h323debug)
ast_log(LOG_DEBUG, "Extension: %s Host: %s\n", pvt->exten, host); ast_log(LOG_DEBUG, "Extension: %s Host: %s\n", pvt->exten, host);
@ -1906,8 +1906,7 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
ast_rtp_get_us(pvt->rtp, &us); ast_rtp_get_us(pvt->rtp, &us);
ast_mutex_unlock(&pvt->lock); ast_mutex_unlock(&pvt->lock);
strncpy(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr)); ast_copy_string(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr));
info->addr[sizeof(info->addr)-1] = '\0';
info->port = ntohs(us.sin_port); info->port = ntohs(us.sin_port);
if (h323debug) if (h323debug)
ast_log(LOG_DEBUG, "Sending RTP 'US' %s:%d\n", info->addr, info->port); ast_log(LOG_DEBUG, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
@ -2129,8 +2128,8 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
/* Decide if we are allowing Gatekeeper routed calls*/ /* Decide if we are allowing Gatekeeper routed calls*/
if ((!strcasecmp(cd->sourceIp, gatekeeper)) && (gkroute == -1) && !gatekeeper_disable) { if ((!strcasecmp(cd->sourceIp, gatekeeper)) && (gkroute == -1) && !gatekeeper_disable) {
if (!ast_strlen_zero(cd->call_dest_e164)) { if (!ast_strlen_zero(cd->call_dest_e164)) {
strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten));
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, default_context, sizeof(pvt->context));
} else { } else {
alias = find_alias(cd->call_dest_alias, 1); alias = find_alias(cd->call_dest_alias, 1);
if (!alias) { if (!alias) {
@ -2138,8 +2137,8 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
oh323_destroy(pvt); oh323_destroy(pvt);
return NULL; return NULL;
} }
strncpy(pvt->exten, alias->name, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, alias->name, sizeof(pvt->exten));
strncpy(pvt->context, alias->context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, alias->context, sizeof(pvt->context));
} }
} else { } else {
/* Either this call is not from the Gatekeeper /* Either this call is not from the Gatekeeper
@ -2156,11 +2155,11 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
oh323_destroy(pvt); oh323_destroy(pvt);
return NULL; return NULL;
} }
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, default_context, sizeof(pvt->context));
if (!ast_strlen_zero(pvt->cd.call_dest_e164)) { if (!ast_strlen_zero(pvt->cd.call_dest_e164)) {
strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten));
} else { } else {
strncpy(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten));
} }
if (h323debug) if (h323debug)
ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten); ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
@ -2174,9 +2173,9 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
ASTOBJ_UNREF(user, oh323_destroy_user); ASTOBJ_UNREF(user, oh323_destroy_user);
return NULL; return NULL;
} }
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, default_context, sizeof(pvt->context));
} else { } else {
strncpy(pvt->context, user->context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, user->context, sizeof(pvt->context));
} }
pvt->exten[0] = 'i'; pvt->exten[0] = 'i';
pvt->exten[1] = '\0'; pvt->exten[1] = '\0';
@ -2186,16 +2185,16 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
return NULL; /* XXX: Hmmm... Why to setup context if we drop connection immediately??? */ return NULL; /* XXX: Hmmm... Why to setup context if we drop connection immediately??? */
} }
} }
strncpy(pvt->context, user->context, sizeof(pvt->context) - 1); ast_copy_string(pvt->context, user->context, sizeof(pvt->context));
memcpy(&pvt->options, &user->options, sizeof(pvt->options)); memcpy(&pvt->options, &user->options, sizeof(pvt->options));
pvt->jointcapability = pvt->options.capability; pvt->jointcapability = pvt->options.capability;
if (!ast_strlen_zero(pvt->cd.call_dest_e164)) { if (!ast_strlen_zero(pvt->cd.call_dest_e164)) {
strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten));
} else { } else {
strncpy(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten) - 1); ast_copy_string(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten));
} }
if (!ast_strlen_zero(user->accountcode)) { if (!ast_strlen_zero(user->accountcode)) {
strncpy(pvt->accountcode, user->accountcode, sizeof(pvt->accountcode) - 1); ast_copy_string(pvt->accountcode, user->accountcode, sizeof(pvt->accountcode));
} }
if (user->amaflags) { if (user->amaflags) {
pvt->amaflags = user->amaflags; pvt->amaflags = user->amaflags;
@ -2228,7 +2227,7 @@ static int answer_call(unsigned call_reference, const char *token)
return 0; return 0;
} }
/* Check if requested extension@context pair exists in the dialplan */ /* Check if requested extension@context pair exists in the dialplan */
strncpy(tmp_exten, pvt->exten, sizeof(tmp_exten)); ast_copy_string(tmp_exten, pvt->exten, sizeof(tmp_exten));
/* Try to find best extension in specified context */ /* Try to find best extension in specified context */
if ((tmp_exten[0] != '\0') && (tmp_exten[1] == '\0')) { if ((tmp_exten[0] != '\0') && (tmp_exten[1] == '\0')) {
@ -2270,7 +2269,7 @@ static int answer_call(unsigned call_reference, const char *token)
} else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) { } else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) {
if (h323debug) if (h323debug)
ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context); ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
strncpy(pvt->exten, tmp_exten, sizeof(pvt->exten)); ast_copy_string(pvt->exten, tmp_exten, sizeof(pvt->exten));
} }
/* allocate a channel and tell asterisk about it */ /* allocate a channel and tell asterisk about it */
@ -2810,7 +2809,7 @@ static int reload_config(int is_reload)
if (!h323_end_point_exist()) { if (!h323_end_point_exist()) {
h323_end_point_create(); h323_end_point_create();
} }
strncpy(_gatekeeper, gatekeeper, sizeof(_gatekeeper)); ast_copy_string(_gatekeeper, gatekeeper, sizeof(_gatekeeper));
gk_discover = gatekeeper_discover; gk_discover = gatekeeper_discover;
gk_disable = gatekeeper_disable; gk_disable = gatekeeper_disable;
memset(&bindaddr, 0, sizeof(bindaddr)); memset(&bindaddr, 0, sizeof(bindaddr));
@ -2823,7 +2822,7 @@ static int reload_config(int is_reload)
global_options.holdHandling = 0; global_options.holdHandling = 0;
global_options.capability = GLOBAL_CAPABILITY; global_options.capability = GLOBAL_CAPABILITY;
global_options.bridge = 1; /* Do native bridging by default */ global_options.bridge = 1; /* Do native bridging by default */
strncpy(default_context, "default", sizeof(default_context) - 1); strcpy(default_context, "default");
h323_signalling_port = 1720; h323_signalling_port = 1720;
gatekeeper_disable = 1; gatekeeper_disable = 1;
gatekeeper_discover = 0; gatekeeper_discover = 0;
@ -2896,14 +2895,14 @@ static int reload_config(int is_reload)
gatekeeper_discover = 1; gatekeeper_discover = 1;
} else { } else {
gatekeeper_disable = 0; gatekeeper_disable = 0;
strncpy(gatekeeper, v->value, sizeof(gatekeeper) - 1); ast_copy_string(gatekeeper, v->value, sizeof(gatekeeper));
} }
} else if (!strcasecmp(v->name, "secret")) { } else if (!strcasecmp(v->name, "secret")) {
strncpy(secret, v->value, sizeof(secret) - 1); ast_copy_string(secret, v->value, sizeof(secret));
} else if (!strcasecmp(v->name, "AllowGKRouted")) { } else if (!strcasecmp(v->name, "AllowGKRouted")) {
gkroute = ast_true(v->value); gkroute = ast_true(v->value);
} else if (!strcasecmp(v->name, "context")) { } else if (!strcasecmp(v->name, "context")) {
strncpy(default_context, v->value, sizeof(default_context) - 1); ast_copy_string(default_context, v->value, sizeof(default_context));
ast_verbose(VERBOSE_PREFIX_2 "Setting default context to %s\n", default_context); ast_verbose(VERBOSE_PREFIX_2 "Setting default context to %s\n", default_context);
} else if (!strcasecmp(v->name, "UserByAlias")) { } else if (!strcasecmp(v->name, "UserByAlias")) {
userbyalias = ast_true(v->value); userbyalias = ast_true(v->value);

@ -8594,11 +8594,9 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, st
ast_string_field_set(user, dbsecret, v->value); ast_string_field_set(user, dbsecret, v->value);
} else if (!strcasecmp(v->name, "secret")) { } else if (!strcasecmp(v->name, "secret")) {
if (!ast_strlen_zero(user->secret)) { if (!ast_strlen_zero(user->secret)) {
char buf99[100]; char *old = ast_strdupa(user->secret);
strncpy(buf99,user->secret,100); /* just in case some weirdness happens in the string_field_build */
ast_string_field_build(user,secret,"%s;%s",buf99,v->value); ast_string_field_build(user, secret, "%s;%s", old, v->value);
/* strncpy(user->secret + strlen(user->secret), ";", sizeof(user->secret) - strlen(user->secret) - 1);
strncpy(user->secret + strlen(user->secret), v->value, sizeof(user->secret) - strlen(user->secret) - 1); */
} else } else
ast_string_field_set(user, secret, v->value); ast_string_field_set(user, secret, v->value);
} else if (!strcasecmp(v->name, "callerid")) { } else if (!strcasecmp(v->name, "callerid")) {

@ -3642,7 +3642,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
} else if (!strcasecmp(v->name, "port")) { } else if (!strcasecmp(v->name, "port")) {
gw->addr.sin_port = htons(atoi(v->value)); gw->addr.sin_port = htons(atoi(v->value));
} else if (!strcasecmp(v->name, "context")) { } 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")) { } else if (!strcasecmp(v->name, "dtmfmode")) {
if (!strcasecmp(v->value, "inband")) if (!strcasecmp(v->value, "inband"))
dtmfmode = MGCP_DTMF_INBAND; dtmfmode = MGCP_DTMF_INBAND;
@ -3664,9 +3664,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)); ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
} }
} else if (!strcasecmp(v->name, "language")) { } 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")) { } 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")) { } else if (!strcasecmp(v->name, "amaflags")) {
y = ast_cdr_amaflags2int(v->value); y = ast_cdr_amaflags2int(v->value);
if (y < 0) { if (y < 0) {
@ -3675,7 +3675,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
amaflags = y; amaflags = y;
} }
} else if (!strcasecmp(v->name, "musiconhold")) { } 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")) { } else if (!strcasecmp(v->name, "callgroup")) {
cur_callergroup = ast_get_group(v->value); cur_callergroup = ast_get_group(v->value);
} else if (!strcasecmp(v->name, "pickupgroup")) { } else if (!strcasecmp(v->name, "pickupgroup")) {
@ -3689,7 +3689,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
} else if (!strcasecmp(v->name, "canreinvite")) { } else if (!strcasecmp(v->name, "canreinvite")) {
canreinvite = ast_true(v->value); canreinvite = ast_true(v->value);
} else if (!strcasecmp(v->name, "mailbox")) { } 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")) { } else if (!strcasecmp(v->name, "adsi")) {
adsi = ast_true(v->value); adsi = ast_true(v->value);
} else if (!strcasecmp(v->name, "callreturn")) { } else if (!strcasecmp(v->name, "callreturn")) {
@ -3727,19 +3727,18 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock); ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock); ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_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; e->needaudit = 1;
} }
strncpy(gw->wcardep, v->value, sizeof(gw->wcardep) - 1); ast_copy_string(gw->wcardep, v->value, sizeof(gw->wcardep));
/*strncpy(e->name, "aaln/" "*", sizeof(e->name) - 1);*/
/* XXX Should we really check for uniqueness?? XXX */ /* XXX Should we really check for uniqueness?? XXX */
strncpy(e->accountcode, accountcode, sizeof(e->accountcode) - 1); ast_copy_string(e->accountcode, accountcode, sizeof(e->accountcode));
strncpy(e->context, context, sizeof(e->context) - 1); ast_copy_string(e->context, context, sizeof(e->context));
strncpy(e->cid_num, cid_num, sizeof(e->cid_num) - 1); ast_copy_string(e->cid_num, cid_num, sizeof(e->cid_num));
strncpy(e->cid_name, cid_name, sizeof(e->cid_name) - 1); ast_copy_string(e->cid_name, cid_name, sizeof(e->cid_name));
strncpy(e->language, language, sizeof(e->language) - 1); ast_copy_string(e->language, language, sizeof(e->language));
strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1); ast_copy_string(e->musicclass, musicclass, sizeof(e->musicclass));
strncpy(e->mailbox, mailbox, sizeof(e->mailbox) - 1); ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random()); snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random());
e->msgstate = -1; e->msgstate = -1;
e->amaflags = amaflags; e->amaflags = amaflags;
@ -3827,17 +3826,17 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_mutex_init(&e->lock); ast_mutex_init(&e->lock);
ast_mutex_init(&e->rqnt_queue_lock); ast_mutex_init(&e->rqnt_queue_lock);
ast_mutex_init(&e->cmd_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; e->needaudit = 1;
} }
/* XXX Should we really check for uniqueness?? XXX */ /* XXX Should we really check for uniqueness?? XXX */
strncpy(e->accountcode, accountcode, sizeof(e->accountcode) - 1); ast_copy_string(e->accountcode, accountcode, sizeof(e->accountcode));
strncpy(e->context, context, sizeof(e->context) - 1); ast_copy_string(e->context, context, sizeof(e->context));
strncpy(e->cid_num, cid_num, sizeof(e->cid_num) - 1); ast_copy_string(e->cid_num, cid_num, sizeof(e->cid_num));
strncpy(e->cid_name, cid_name, sizeof(e->cid_name) - 1); ast_copy_string(e->cid_name, cid_name, sizeof(e->cid_name));
strncpy(e->language, language, sizeof(e->language) - 1); ast_copy_string(e->language, language, sizeof(e->language));
strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1); ast_copy_string(e->musicclass, musicclass, sizeof(e->musicclass));
strncpy(e->mailbox, mailbox, sizeof(e->mailbox)-1); ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
if (!ast_strlen_zero(mailbox)) { if (!ast_strlen_zero(mailbox)) {
ast_verbose(VERBOSE_PREFIX_3 "Setting mailbox '%s' on %s@%s\n", mailbox, gw->name, e->name); ast_verbose(VERBOSE_PREFIX_3 "Setting mailbox '%s' on %s@%s\n", mailbox, gw->name, e->name);
} }
@ -3890,7 +3889,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
memset(sub, 0, sizeof(struct mgcp_subchannel)); memset(sub, 0, sizeof(struct mgcp_subchannel));
ast_mutex_init(&sub->lock); ast_mutex_init(&sub->lock);
ast_mutex_init(&sub->cx_queue_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->parent = e;
sub->id = i; sub->id = i;
snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random()); snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random());

@ -129,10 +129,10 @@ static struct nbs_pvt *nbs_alloc(void *data)
{ {
struct nbs_pvt *p; struct nbs_pvt *p;
int flags = 0; int flags = 0;
char stream[256] = ""; char stream[256];
char *opts; char *opts;
strncpy(stream, data, sizeof(stream) - 1); ast_copy_string(stream, data, sizeof(stream));
if ((opts = strchr(stream, ':'))) { if ((opts = strchr(stream, ':'))) {
*opts = '\0'; *opts = '\0';
opts++; opts++;
@ -153,7 +153,7 @@ static struct nbs_pvt *nbs_alloc(void *data)
} else } else
flags = NBS_FLAG_OVERSPEAK; flags = NBS_FLAG_OVERSPEAK;
strncpy(p->stream, stream, sizeof(p->stream) - 1); ast_copy_string(p->stream, stream, sizeof(p->stream));
p->nbs = nbs_newstream("asterisk", stream, flags); p->nbs = nbs_newstream("asterisk", stream, flags);
if (!p->nbs) { if (!p->nbs) {
ast_log(LOG_WARNING, "Unable to allocate new NBS stream '%s' with flags %d\n", stream, flags); ast_log(LOG_WARNING, "Unable to allocate new NBS stream '%s' with flags %d\n", stream, flags);
@ -247,8 +247,8 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state)
if (state == AST_STATE_RING) if (state == AST_STATE_RING)
tmp->rings = 1; tmp->rings = 1;
tmp->tech_pvt = i; tmp->tech_pvt = i;
strncpy(tmp->context, context, sizeof(tmp->context)-1); ast_copy_string(tmp->context, context, sizeof(tmp->context));
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1); ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
ast_string_field_set(tmp, language, ""); ast_string_field_set(tmp, language, "");
i->owner = tmp; i->owner = tmp;
i->u = ast_module_user_add(tmp); i->u = ast_module_user_add(tmp);

@ -313,12 +313,12 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
} }
/* the standard format of ast->callerid is: "name" <number>, but not always complete */ /* the standard format of ast->callerid is: "name" <number>, but not always complete */
if (ast_strlen_zero(ast->cid.cid_name)) if (ast_strlen_zero(ast->cid.cid_name))
strncpy(cid.name, DEFAULT_CALLER_ID, sizeof(cid.name) - 1); strcpy(cid.name, DEFAULT_CALLER_ID);
else else
strncpy(cid.name, ast->cid.cid_name, sizeof(cid.name) - 1); ast_copy_string(cid.name, ast->cid.cid_name, sizeof(cid.name));
if (ast->cid.cid_num) if (ast->cid.cid_num)
strncpy(cid.number, ast->cid.cid_num, sizeof(cid.number) - 1); ast_copy_string(cid.number, ast->cid.cid_num, sizeof(cid.number));
p = ast->tech_pvt; p = ast->tech_pvt;
@ -873,11 +873,11 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
if (state == AST_STATE_RING) if (state == AST_STATE_RING)
tmp->rings = 1; tmp->rings = 1;
tmp->tech_pvt = i; tmp->tech_pvt = i;
strncpy(tmp->context, context, sizeof(tmp->context)-1); ast_copy_string(tmp->context, context, sizeof(tmp->context));
if (!ast_strlen_zero(i->ext)) if (!ast_strlen_zero(i->ext))
strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1); ast_copy_string(tmp->exten, i->ext, sizeof(tmp->exten));
else else
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1); strcpy(tmp->exten, "s");
if (!ast_strlen_zero(i->language)) if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language); ast_string_field_set(tmp, language, i->language);
@ -1213,15 +1213,15 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
tmp->lastinput = -1; tmp->lastinput = -1;
tmp->ministate = 0; tmp->ministate = 0;
memset(tmp->ext, 0, sizeof(tmp->ext)); memset(tmp->ext, 0, sizeof(tmp->ext));
strncpy(tmp->language, language, sizeof(tmp->language)-1); ast_copy_string(tmp->language, language, sizeof(tmp->language));
strncpy(tmp->dev, iface, sizeof(tmp->dev)-1); ast_copy_string(tmp->dev, iface, sizeof(tmp->dev));
strncpy(tmp->context, context, sizeof(tmp->context)-1); ast_copy_string(tmp->context, context, sizeof(tmp->context));
tmp->next = NULL; tmp->next = NULL;
tmp->obuflen = 0; tmp->obuflen = 0;
tmp->dialtone = 0; tmp->dialtone = 0;
tmp->cpt = 0; tmp->cpt = 0;
strncpy(tmp->cid_num, cid_num, sizeof(tmp->cid_num)-1); ast_copy_string(tmp->cid_num, cid_num, sizeof(tmp->cid_num));
strncpy(tmp->cid_name, cid_name, sizeof(tmp->cid_name)-1); ast_copy_string(tmp->cid_name, cid_name, sizeof(tmp->cid_name));
tmp->txgain = txgain; tmp->txgain = txgain;
ioctl(tmp->fd, PHONE_PLAY_VOLUME, tmp->txgain); ioctl(tmp->fd, PHONE_PLAY_VOLUME, tmp->txgain);
tmp->rxgain = rxgain; tmp->rxgain = rxgain;
@ -1392,7 +1392,7 @@ static int load_module(void)
} else if (!strcasecmp(v->name, "silencesupression")) { } else if (!strcasecmp(v->name, "silencesupression")) {
silencesupression = ast_true(v->value); silencesupression = ast_true(v->value);
} else if (!strcasecmp(v->name, "language")) { } 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, "callerid")) { } else if (!strcasecmp(v->name, "callerid")) {
ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num)); ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
} else if (!strcasecmp(v->name, "mode")) { } else if (!strcasecmp(v->name, "mode")) {
@ -1411,7 +1411,7 @@ static int load_module(void)
else else
ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value); ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value);
} else if (!strcasecmp(v->name, "context")) { } 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, "format")) { } else if (!strcasecmp(v->name, "format")) {
if (!strcasecmp(v->value, "g723.1")) { if (!strcasecmp(v->value, "g723.1")) {
prefformat = AST_FORMAT_G723_1; prefformat = AST_FORMAT_G723_1;

@ -8630,7 +8630,7 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
/* This is an attended transfer */ /* This is an attended transfer */
referdata->attendedtransfer = 1; referdata->attendedtransfer = 1;
strncpy(referdata->replaces_callid, ptr+9, sizeof(referdata->replaces_callid)); ast_copy_string(referdata->replaces_callid, ptr+9, sizeof(referdata->replaces_callid));
ast_uri_decode(referdata->replaces_callid); ast_uri_decode(referdata->replaces_callid);
if ((ptr = strchr(referdata->replaces_callid, ';'))) /* Find options */ { if ((ptr = strchr(referdata->replaces_callid, ';'))) /* Find options */ {
*ptr++ = '\0'; *ptr++ = '\0';
@ -8677,9 +8677,9 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
if ((urioption = strchr(ptr, ';'))) if ((urioption = strchr(ptr, ';')))
*urioption++ = '\0'; *urioption++ = '\0';
/* Save the domain for the dial plan */ /* Save the domain for the dial plan */
strncpy(referdata->refer_to_domain, ptr, sizeof(referdata->refer_to_domain)); ast_copy_string(referdata->refer_to_domain, ptr, sizeof(referdata->refer_to_domain));
if (urioption) if (urioption)
strncpy(referdata->refer_to_urioption, urioption, sizeof(referdata->refer_to_urioption)); ast_copy_string(referdata->refer_to_urioption, urioption, sizeof(referdata->refer_to_urioption));
} }
if ((ptr = strchr(refer_to, ';'))) /* Remove options */ if ((ptr = strchr(refer_to, ';'))) /* Remove options */
@ -8704,7 +8704,7 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
S_OR(transferer->context, default_context)); S_OR(transferer->context, default_context));
} }
strncpy(referdata->refer_to_context, transfer_context, sizeof(referdata->refer_to_context)); ast_copy_string(referdata->refer_to_context, transfer_context, sizeof(referdata->refer_to_context));
/* Either an existing extension or the parking extension */ /* Either an existing extension or the parking extension */
if (ast_exists_extension(NULL, transfer_context, refer_to, 1, NULL) ) { if (ast_exists_extension(NULL, transfer_context, refer_to, 1, NULL) ) {

@ -678,7 +678,7 @@ int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
int len = strlen(cdr->userfield); int len = strlen(cdr->userfield);
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1); ast_copy_string(cdr->userfield + len, userfield, sizeof(cdr->userfield) - len);
} }
return 0; return 0;

@ -1437,8 +1437,7 @@ char **ast_cli_completion_matches(const char *text, const char *word)
if (!(retstr = ast_malloc(max_equal + 1))) if (!(retstr = ast_malloc(max_equal + 1)))
return NULL; return NULL;
strncpy(retstr, match_list[1], max_equal); ast_copy_string(retstr, match_list[1], max_equal + 1);
retstr[max_equal] = '\0';
match_list[0] = retstr; match_list[0] = retstr;
/* ensure that the array is NULL terminated */ /* ensure that the array is NULL terminated */

@ -203,8 +203,7 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen)
if (data.size) { if (data.size) {
((char *)data.data)[data.size - 1] = '\0'; ((char *)data.data)[data.size - 1] = '\0';
/* Make sure that we don't write too much to the dst pointer or we don't read too much from the source pointer */ /* Make sure that we don't write too much to the dst pointer or we don't read too much from the source pointer */
strncpy(value, data.data, (valuelen > data.size) ? data.size : valuelen); ast_copy_string(value, data.data, (valuelen > data.size) ? data.size : valuelen);
value[valuelen - 1] = '\0';
} else { } else {
ast_log(LOG_NOTICE, "Strange, empty value for /%s/%s\n", family, keys); ast_log(LOG_NOTICE, "Strange, empty value for /%s/%s\n", family, keys);
} }

@ -125,7 +125,7 @@ struct ast_frame *ast_read_image(char *filename, const char *preflang, int forma
AST_LIST_TRAVERSE(&imagers, i, list) { AST_LIST_TRAVERSE(&imagers, i, list) {
if (i->format & format) { if (i->format & format) {
char *stringp=NULL; char *stringp=NULL;
strncpy(tmp, i->exts, sizeof(tmp)-1); ast_copy_string(tmp, i->exts, sizeof(tmp));
stringp=tmp; stringp=tmp;
e = strsep(&stringp, "|"); e = strsep(&stringp, "|");
while(e) { while(e) {

@ -449,7 +449,7 @@ char *ast_uri_encode(const char *string, char *outbuf, int buflen, int doreserve
char *out = NULL; char *out = NULL;
char *buf = NULL; char *buf = NULL;
strncpy(outbuf, string, buflen); ast_copy_string(outbuf, string, buflen);
/* If there's no characters to convert, just go through and don't do anything */ /* If there's no characters to convert, just go through and don't do anything */
while (*ptr) { while (*ptr) {

@ -129,7 +129,7 @@ static void dump_string(char *output, int maxlen, void *value, int len)
maxlen--; maxlen--;
if (maxlen > len) if (maxlen > len)
maxlen = len; maxlen = len;
strncpy(output,value, maxlen); strncpy(output, value, maxlen);
output[maxlen] = '\0'; output[maxlen] = '\0';
} }

@ -870,13 +870,13 @@ static void check_includes(pval *includes)
static void check_timerange(pval *p) static void check_timerange(pval *p)
{ {
char times[200]; char *times;
char *e; char *e;
int s1, s2; int s1, s2;
int e1, e2; int e1, e2;
times = ast_strdupa(p->u1.str);
strncpy(times, p->u1.str, sizeof(times));
/* Star is all times */ /* Star is all times */
if (ast_strlen_zero(times) || !strcmp(times, "*")) { if (ast_strlen_zero(times) || !strcmp(times, "*")) {
return; return;
@ -938,12 +938,12 @@ static char *days[] =
/*! \brief get_dow: Get day of week */ /*! \brief get_dow: Get day of week */
static void check_dow(pval *DOW) static void check_dow(pval *DOW)
{ {
char dow[200]; char *dow;
char *c; char *c;
/* The following line is coincidence, really! */ /* The following line is coincidence, really! */
int s, e; int s, e;
strncpy(dow,DOW->u1.str,sizeof(dow)); dow = ast_strdupa(DOW->u1.str);
/* Check for all days */ /* Check for all days */
if (ast_strlen_zero(dow) || !strcmp(dow, "*")) if (ast_strlen_zero(dow) || !strcmp(dow, "*"))
@ -977,12 +977,13 @@ static void check_dow(pval *DOW)
static void check_day(pval *DAY) static void check_day(pval *DAY)
{ {
char day[200]; char *day;
char *c; char *c;
/* The following line is coincidence, really! */ /* The following line is coincidence, really! */
int s, e; int s, e;
strncpy(day,DAY->u1.str,sizeof(day)); day = ast_strdupa(DAY->u1.str);
/* Check for all days */ /* Check for all days */
if (ast_strlen_zero(day) || !strcmp(day, "*")) { if (ast_strlen_zero(day) || !strcmp(day, "*")) {
return; return;
@ -1039,12 +1040,13 @@ static char *months[] =
static void check_month(pval *MON) static void check_month(pval *MON)
{ {
char mon[200]; char *mon;
char *c; char *c;
/* The following line is coincidence, really! */ /* The following line is coincidence, really! */
int s, e; int s, e;
strncpy(mon,MON->u1.str,sizeof(mon)); mon = ast_strdupa(MON->u1.str);
/* Check for all days */ /* Check for all days */
if (ast_strlen_zero(mon) || !strcmp(mon, "*")) if (ast_strlen_zero(mon) || !strcmp(mon, "*"))
return ; return ;
@ -1993,14 +1995,14 @@ int is_empty(char *arg)
int option_matches_j( struct argdesc *should, pval *is, struct argapp *app) int option_matches_j( struct argdesc *should, pval *is, struct argapp *app)
{ {
struct argchoice *ac; struct argchoice *ac;
char opcop[400],*q,*p; char *opcop,*q,*p;
switch (should->dtype) { switch (should->dtype) {
case ARGD_OPTIONSET: case ARGD_OPTIONSET:
if ( strstr(is->u1.str,"${") ) if ( strstr(is->u1.str,"${") )
return 0; /* no checking anything if there's a var reference in there! */ return 0; /* no checking anything if there's a var reference in there! */
strncpy(opcop,is->u1.str,sizeof(opcop)); opcop = ast_strdupa(is->u1.str);
for (q=opcop;*q;q++) { /* erase the innards of X(innard) type arguments, so we don't get confused later */ for (q=opcop;*q;q++) { /* erase the innards of X(innard) type arguments, so we don't get confused later */
if ( *q == '(' ) { if ( *q == '(' ) {
@ -2055,7 +2057,7 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app)
int option_matches( struct argdesc *should, pval *is, struct argapp *app) int option_matches( struct argdesc *should, pval *is, struct argapp *app)
{ {
struct argchoice *ac; struct argchoice *ac;
char opcop[400]; char *opcop;
switch (should->dtype) { switch (should->dtype) {
case ARGD_STRING: case ARGD_STRING:
@ -2090,7 +2092,7 @@ int option_matches( struct argdesc *should, pval *is, struct argapp *app)
break; break;
case ARGD_OPTIONSET: case ARGD_OPTIONSET:
strncpy(opcop,is->u1.str,sizeof(opcop)); opcop = ast_strdupa(is->u1.str);
for (ac=app->opts; ac; ac=ac->next) { for (ac=app->opts; ac; ac=ac->next) {
if (strlen(ac->name)>1 && strchr(ac->name,'(') == 0 && strcmp(ac->name,is->u1.str) == 0) /* multichar option, no parens, and a match? */ if (strlen(ac->name)>1 && strchr(ac->name,'(') == 0 && strcmp(ac->name,is->u1.str) == 0) /* multichar option, no parens, and a match? */
@ -2182,7 +2184,7 @@ void check_switch_expr(pval *item, struct argapp *apps)
{ {
#ifdef AAL_ARGCHECK #ifdef AAL_ARGCHECK
/* get and clean the variable name */ /* get and clean the variable name */
char buff1[1024],*p; char *buff1, *p;
struct argapp *a,*a2; struct argapp *a,*a2;
struct appsetvar *v,*v2; struct appsetvar *v,*v2;
struct argchoice *c; struct argchoice *c;
@ -2192,7 +2194,8 @@ void check_switch_expr(pval *item, struct argapp *apps)
while (p && *p && (*p == ' ' || *p == '\t' || *p == '$' || *p == '{' ) ) while (p && *p && (*p == ' ' || *p == '\t' || *p == '$' || *p == '{' ) )
p++; p++;
strncpy(buff1,p,sizeof(buff1)); buff1 = ast_strdupa(p);
while (strlen(buff1) > 0 && ( buff1[strlen(buff1)-1] == '}' || buff1[strlen(buff1)-1] == ' ' || buff1[strlen(buff1)-1] == '\t')) while (strlen(buff1) > 0 && ( buff1[strlen(buff1)-1] == '}' || buff1[strlen(buff1)-1] == ' ' || buff1[strlen(buff1)-1] == '\t'))
buff1[strlen(buff1)-1] = 0; buff1[strlen(buff1)-1] = 0;
/* buff1 now contains the variable name */ /* buff1 now contains the variable name */

@ -97,7 +97,7 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
case MODE_MATCH: case MODE_MATCH:
default: default:
ematch = "exten"; ematch = "exten";
strncpy(rexten, exten, sizeof(rexten) - 1); ast_copy_string(rexten, exten, sizeof(rexten));
} }
var = ast_load_realtime(table, ematch, rexten, "context", context, "priority", pri, NULL); var = ast_load_realtime(table, ematch, rexten, "context", context, "priority", pri, NULL);
if (!var) { if (!var) {
@ -183,7 +183,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
for (v = var; v ; v = v->next) { for (v = var; v ; v = v->next) {
if (!strcasecmp(v->name, "app")) if (!strcasecmp(v->name, "app"))
strncpy(app, v->value, sizeof(app) -1 ); ast_copy_string(app, v->value, sizeof(app));
else if (!strcasecmp(v->name, "appdata")) else if (!strcasecmp(v->name, "appdata"))
tmp = ast_strdupa(v->value); tmp = ast_strdupa(v->value);
} }

@ -166,11 +166,11 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
printf("'%s' is '%s' at line %d\n", buf, c, lineno); printf("'%s' is '%s' at line %d\n", buf, c, lineno);
#endif #endif
if (!strcasecmp(buf, "channel")) { if (!strcasecmp(buf, "channel")) {
strncpy(o->tech, c, sizeof(o->tech) - 1); ast_copy_string(o->tech, c, sizeof(o->tech));
if ((c2 = strchr(o->tech, '/'))) { if ((c2 = strchr(o->tech, '/'))) {
*c2 = '\0'; *c2 = '\0';
c2++; c2++;
strncpy(o->dest, c2, sizeof(o->dest) - 1); ast_copy_string(o->dest, c2, sizeof(o->dest));
} else { } else {
ast_log(LOG_NOTICE, "Channel should be in form Tech/Dest at line %d of %s\n", lineno, fn); ast_log(LOG_NOTICE, "Channel should be in form Tech/Dest at line %d of %s\n", lineno, fn);
o->tech[0] = '\0'; o->tech[0] = '\0';
@ -178,18 +178,18 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
} else if (!strcasecmp(buf, "callerid")) { } else if (!strcasecmp(buf, "callerid")) {
ast_callerid_split(c, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num)); ast_callerid_split(c, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
} else if (!strcasecmp(buf, "application")) { } else if (!strcasecmp(buf, "application")) {
strncpy(o->app, c, sizeof(o->app) - 1); ast_copy_string(o->app, c, sizeof(o->app));
} else if (!strcasecmp(buf, "data")) { } else if (!strcasecmp(buf, "data")) {
strncpy(o->data, c, sizeof(o->data) - 1); ast_copy_string(o->data, c, sizeof(o->data));
} else if (!strcasecmp(buf, "maxretries")) { } else if (!strcasecmp(buf, "maxretries")) {
if (sscanf(c, "%d", &o->maxretries) != 1) { if (sscanf(c, "%d", &o->maxretries) != 1) {
ast_log(LOG_WARNING, "Invalid max retries at line %d of %s\n", lineno, fn); ast_log(LOG_WARNING, "Invalid max retries at line %d of %s\n", lineno, fn);
o->maxretries = 0; o->maxretries = 0;
} }
} else if (!strcasecmp(buf, "context")) { } else if (!strcasecmp(buf, "context")) {
strncpy(o->context, c, sizeof(o->context) - 1); ast_copy_string(o->context, c, sizeof(o->context));
} else if (!strcasecmp(buf, "extension")) { } else if (!strcasecmp(buf, "extension")) {
strncpy(o->exten, c, sizeof(o->exten) - 1); ast_copy_string(o->exten, c, sizeof(o->exten));
} else if (!strcasecmp(buf, "priority")) { } else if (!strcasecmp(buf, "priority")) {
if ((sscanf(c, "%d", &o->priority) != 1) || (o->priority < 1)) { if ((sscanf(c, "%d", &o->priority) != 1) || (o->priority < 1)) {
ast_log(LOG_WARNING, "Invalid priority at line %d of %s\n", lineno, fn); ast_log(LOG_WARNING, "Invalid priority at line %d of %s\n", lineno, fn);
@ -240,7 +240,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
ast_log(LOG_NOTICE, "Syntax error at line %d of %s\n", lineno, fn); ast_log(LOG_NOTICE, "Syntax error at line %d of %s\n", lineno, fn);
} }
} }
strncpy(o->fn, fn, sizeof(o->fn) - 1); ast_copy_string(o->fn, fn, sizeof(o->fn));
if (ast_strlen_zero(o->tech) || ast_strlen_zero(o->dest) || (ast_strlen_zero(o->app) && ast_strlen_zero(o->exten))) { if (ast_strlen_zero(o->tech) || ast_strlen_zero(o->dest) || (ast_strlen_zero(o->app) && ast_strlen_zero(o->exten))) {
ast_log(LOG_WARNING, "At least one of app or extension must be specified, along with tech and dest in file %s\n", fn); ast_log(LOG_WARNING, "At least one of app or extension must be specified, along with tech and dest in file %s\n", fn);
return -1; return -1;

@ -1114,10 +1114,9 @@ static void adsi_load(void)
if (!sname) if (!sname)
sname = name; sname = name;
if (x < ADSI_MAX_SPEED_DIAL) { if (x < ADSI_MAX_SPEED_DIAL) {
/* Up to 20 digits */
ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0])); ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0]));
strncpy(speeddial[x][1], name, 18); ast_copy_string(speeddial[x][1], name, 18);
strncpy(speeddial[x][2], sname, 7); ast_copy_string(speeddial[x][2], sname, 7);
x++; x++;
} }
} }

Loading…
Cancel
Save