mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
more ast_copy_string conversions
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6075 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -757,7 +757,7 @@ static int handle_setcontext(struct ast_channel *chan, AGI *agi, int argc, char
|
||||
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
strncpy(chan->context, argv[2], sizeof(chan->context)-1);
|
||||
ast_copy_string(chan->context, argv[2], sizeof(chan->context));
|
||||
fdprintf(agi->fd, "200 result=0\n");
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ static int handle_setextension(struct ast_channel *chan, AGI *agi, int argc, cha
|
||||
{
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
strncpy(chan->exten, argv[2], sizeof(chan->exten)-1);
|
||||
ast_copy_string(chan->exten, argv[2], sizeof(chan->exten));
|
||||
fdprintf(agi->fd, "200 result=0\n");
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
@@ -1028,7 +1028,7 @@ static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char
|
||||
char *l = NULL, *n = NULL;
|
||||
|
||||
if (argv[2]) {
|
||||
strncpy(tmp, argv[2], sizeof(tmp) - 1);
|
||||
ast_copy_string(tmp, argv[2], sizeof(tmp));
|
||||
ast_callerid_parse(tmp, &n, &l);
|
||||
if (l)
|
||||
ast_shrink_phone_number(l);
|
||||
@@ -1925,7 +1925,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
|
||||
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
|
||||
return -1;
|
||||
}
|
||||
strncpy(buf, data, sizeof(buf) - 1);
|
||||
ast_copy_string(buf, data, sizeof(buf));
|
||||
|
||||
memset(&agi, 0, sizeof(agi));
|
||||
while ((stringp = strsep(&tmp, "|"))) {
|
||||
|
@@ -217,9 +217,9 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
|
||||
if (found)
|
||||
ast_mutex_lock(&keylock);
|
||||
/* First the filename */
|
||||
strncpy(key->fn, ffname, sizeof(key->fn) - 1);
|
||||
ast_copy_string(key->fn, ffname, sizeof(key->fn));
|
||||
/* Then the name */
|
||||
strncpy(key->name, fname, sizeof(key->name) - 1);
|
||||
ast_copy_string(key->name, fname, sizeof(key->name));
|
||||
key->ktype = ktype;
|
||||
/* Yes, assume we're going to be deleted */
|
||||
key->delme = 1;
|
||||
@@ -529,7 +529,7 @@ static int init_keys(int fd, int argc, char *argv[])
|
||||
/* Reload keys that need pass codes now */
|
||||
if (key->ktype & KEY_NEEDS_PASSCODE) {
|
||||
kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1;
|
||||
strncpy(tmp, kn, sizeof(tmp) - 1);
|
||||
ast_copy_string(tmp, kn, sizeof(tmp));
|
||||
try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign);
|
||||
}
|
||||
key = key->next;
|
||||
|
@@ -90,7 +90,7 @@ static int handle_add_indication(int fd, int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
memset(tz,0,sizeof(struct tone_zone));
|
||||
strncpy(tz->country,argv[2],sizeof(tz->country)-1);
|
||||
ast_copy_string(tz->country,argv[2],sizeof(tz->country));
|
||||
if (ast_register_indication_country(tz)) {
|
||||
ast_log(LOG_WARNING, "Unable to register new country\n");
|
||||
free(tz);
|
||||
@@ -176,7 +176,7 @@ static int handle_show_indications(int fd, int argc, char *argv[])
|
||||
j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadance[i]);
|
||||
}
|
||||
if (tz->nrringcadance) j--;
|
||||
strncpy(buf+j,"\n",sizeof(buf)-j-1);
|
||||
ast_copy_string(buf+j,"\n",sizeof(buf)-j);
|
||||
ast_cli(fd,buf);
|
||||
for (ts=tz->tones; ts; ts=ts->next)
|
||||
ast_cli(fd,"%-7.7s %-15.15s %s\n",tz->country,ts->name,ts->data);
|
||||
@@ -254,12 +254,12 @@ static int ind_load_module(void)
|
||||
return -1;
|
||||
}
|
||||
memset(tones,0,sizeof(struct tone_zone));
|
||||
strncpy(tones->country,cxt,sizeof(tones->country) - 1);
|
||||
ast_copy_string(tones->country,cxt,sizeof(tones->country));
|
||||
|
||||
v = ast_variable_browse(cfg, cxt);
|
||||
while(v) {
|
||||
if (!strcasecmp(v->name, "description")) {
|
||||
strncpy(tones->description, v->value, sizeof(tones->description)-1);
|
||||
ast_copy_string(tones->description, v->value, sizeof(tones->description));
|
||||
} else if (!strcasecmp(v->name,"ringcadance")) {
|
||||
char *ring,*rings = ast_strdupa(v->value);
|
||||
c = rings;
|
||||
@@ -295,8 +295,8 @@ static int ind_load_module(void)
|
||||
return -1;
|
||||
}
|
||||
memset(azone,0,sizeof(struct tone_zone));
|
||||
strncpy(azone->country, country, sizeof(azone->country) - 1);
|
||||
strncpy(azone->alias, cxt, sizeof(azone->alias)-1);
|
||||
ast_copy_string(azone->country, country, sizeof(azone->country));
|
||||
ast_copy_string(azone->alias, cxt, sizeof(azone->alias));
|
||||
if (ast_register_indication_country(azone)) {
|
||||
ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);
|
||||
free(tones);
|
||||
|
@@ -124,7 +124,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
|
||||
directory ? "" : ast_config_AST_MONITOR_DIR, fname_base);
|
||||
snprintf(monitor->write_filename, FILENAME_MAX, "%s/%s-out",
|
||||
directory ? "" : ast_config_AST_MONITOR_DIR, fname_base);
|
||||
strncpy(monitor->filename_base, fname_base, sizeof(monitor->filename_base) - 1);
|
||||
ast_copy_string(monitor->filename_base, fname_base, sizeof(monitor->filename_base));
|
||||
} else {
|
||||
ast_mutex_lock(&monitorlock);
|
||||
snprintf(monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",
|
||||
@@ -264,7 +264,7 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
|
||||
snprintf(tmp, sizeof(tmp), "%s \"%s/%s-in.%s\" \"%s/%s-out.%s\" \"%s/%s.%s\" %s &", execute, dir, name, format, dir, name, format, dir, name, format,execute_args);
|
||||
if (delfiles) {
|
||||
snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
|
||||
strncpy(tmp, tmp2, sizeof(tmp) - 1);
|
||||
ast_copy_string(tmp, tmp2, sizeof(tmp));
|
||||
}
|
||||
ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
|
||||
if (ast_safe_system(tmp) == -1)
|
||||
@@ -440,7 +440,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
|
||||
return 0;
|
||||
}
|
||||
memset(fname, 0, FILENAME_MAX);
|
||||
strncpy(fname, c->name, FILENAME_MAX-1);
|
||||
ast_copy_string(fname, c->name, FILENAME_MAX);
|
||||
/* Channels have the format technology/channel_name - have to replace that / */
|
||||
if ((d=strchr(fname, '/'))) *d='-';
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ static int odbc_write(struct odbc_list *registry, char *name, odbc_obj *obj)
|
||||
int x = 0;
|
||||
for (x = 0; x < MAX_ODBC_HANDLES; x++) {
|
||||
if (!registry[x].used) {
|
||||
strncpy(registry[x].name, name, sizeof(registry[x].name) - 1);
|
||||
ast_copy_string(registry[x].name, name, sizeof(registry[x].name));
|
||||
registry[x].obj = obj;
|
||||
registry[x].used = 1;
|
||||
return 1;
|
||||
|
@@ -116,7 +116,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
|
||||
memset(osp, 0, sizeof(struct osp_provider));
|
||||
osp->handle = -1;
|
||||
}
|
||||
strncpy(osp->name, cat, sizeof(osp->name) - 1);
|
||||
ast_copy_string(osp->name, cat, sizeof(osp->name));
|
||||
snprintf(osp->localpvtkey, sizeof(osp->localpvtkey) ,"%s/%s-privatekey.pem", ast_config_AST_KEY_DIR, cat);
|
||||
snprintf(osp->localcert, sizeof(osp->localpvtkey), "%s/%s-localcert.pem", ast_config_AST_KEY_DIR, cat);
|
||||
osp->maxconnections=OSP_DEFAULT_MAX_CONNECTIONS;
|
||||
@@ -129,18 +129,18 @@ static int osp_build(struct ast_config *cfg, char *cat)
|
||||
while(v) {
|
||||
if (!strcasecmp(v->name, "privatekey")) {
|
||||
if (v->value[0] == '/')
|
||||
strncpy(osp->localpvtkey, v->value, sizeof(osp->localpvtkey) - 1);
|
||||
ast_copy_string(osp->localpvtkey, v->value, sizeof(osp->localpvtkey));
|
||||
else
|
||||
snprintf(osp->localpvtkey, sizeof(osp->localpvtkey), "%s/%s", ast_config_AST_KEY_DIR , v->value);
|
||||
} else if (!strcasecmp(v->name, "localcert")) {
|
||||
if (v->value[0] == '/')
|
||||
strncpy(osp->localcert, v->value, sizeof(osp->localcert) - 1);
|
||||
ast_copy_string(osp->localcert, v->value, sizeof(osp->localcert));
|
||||
else
|
||||
snprintf(osp->localcert, sizeof(osp->localcert), "%s/%s", ast_config_AST_KEY_DIR, v->value);
|
||||
} else if (!strcasecmp(v->name, "cacert")) {
|
||||
if (osp->cacount < MAX_CERTS) {
|
||||
if (v->value[0] == '/')
|
||||
strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]) - 1);
|
||||
ast_copy_string(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]));
|
||||
else
|
||||
snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value);
|
||||
osp->cacount++;
|
||||
@@ -148,7 +148,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
|
||||
ast_log(LOG_WARNING, "Too many CA Certificates at line %d\n", v->lineno);
|
||||
} else if (!strcasecmp(v->name, "servicepoint")) {
|
||||
if (osp->spcount < MAX_SERVICEPOINTS) {
|
||||
strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]) - 1);
|
||||
ast_copy_string(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]));
|
||||
osp->spcount++;
|
||||
} else
|
||||
ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno);
|
||||
@@ -173,7 +173,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
|
||||
} else
|
||||
ast_log(LOG_WARNING, "timeout should be an integer from 200 to 10000, not '%s' at line %d\n", v->value, v->lineno);
|
||||
} else if (!strcasecmp(v->name, "source")) {
|
||||
strncpy(osp->source, v->value, sizeof(osp->source) - 1);
|
||||
ast_copy_string(osp->source, v->value, sizeof(osp->source));
|
||||
}
|
||||
v = v->next;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
|
||||
*handle = -1;
|
||||
if (!callerid)
|
||||
callerid = "";
|
||||
strncpy(tmp, callerid, sizeof(tmp) - 1);
|
||||
ast_copy_string(tmp, callerid, sizeof(tmp));
|
||||
ast_callerid_parse(tmp, &n, &l);
|
||||
if (!l)
|
||||
l = "";
|
||||
@@ -463,7 +463,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
|
||||
if (OSPPTransactionNew(osp->handle, handle)) {
|
||||
ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
|
||||
} else {
|
||||
strncpy(source, osp->source, sizeof(source) - 1);
|
||||
ast_copy_string(source, osp->source, sizeof(source));
|
||||
res = 1;
|
||||
}
|
||||
break;
|
||||
@@ -516,7 +516,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
||||
|
||||
if (!callerid)
|
||||
callerid = "";
|
||||
strncpy(tmp, callerid, sizeof(tmp) - 1);
|
||||
ast_copy_string(tmp, callerid, sizeof(tmp));
|
||||
ast_callerid_parse(tmp, &n, &l);
|
||||
if (!l)
|
||||
l = "";
|
||||
@@ -528,7 +528,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
||||
callerid = l;
|
||||
|
||||
if (chan) {
|
||||
strncpy(uniqueid, chan->uniqueid, sizeof(uniqueid) - 1);
|
||||
ast_copy_string(uniqueid, chan->uniqueid, sizeof(uniqueid));
|
||||
cres = ast_autoservice_start(chan);
|
||||
if (cres < 0)
|
||||
return cres;
|
||||
@@ -540,7 +540,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
||||
if (OSPPTransactionNew(osp->handle, &result->handle)) {
|
||||
ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
|
||||
} else {
|
||||
strncpy(source, osp->source, sizeof(source) - 1);
|
||||
ast_copy_string(source, osp->source, sizeof(source));
|
||||
res = 1;
|
||||
}
|
||||
break;
|
||||
@@ -573,15 +573,15 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
||||
destination[strlen(destination) - 1] = '\0';
|
||||
switch(prot) {
|
||||
case OSPE_DEST_PROT_H323_SETUP:
|
||||
strncpy(result->tech, "H323", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "H323", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
case OSPE_DEST_PROT_SIP:
|
||||
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "SIP", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
case OSPE_DEST_PROT_IAX:
|
||||
strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "IAX", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
default:
|
||||
@@ -656,15 +656,15 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
|
||||
destination[strlen(destination) - 1] = '\0';
|
||||
switch(prot) {
|
||||
case OSPE_DEST_PROT_H323_SETUP:
|
||||
strncpy(result->tech, "H323", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "H323", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
case OSPE_DEST_PROT_SIP:
|
||||
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "SIP", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
case OSPE_DEST_PROT_IAX:
|
||||
strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
|
||||
ast_copy_string(result->tech, "IAX", sizeof(result->tech));
|
||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user