diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-07-10 23:21:39 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-07-10 23:21:39 +0000 |
commit | cbc8a4b7d2382b98f0666fd6a81ce4cca5a4fc22 (patch) | |
tree | cd22ca2f4e2c7b9edcb1c3ee5c724068bae3bc36 /res | |
parent | d99da55a16b32f4463c40d504fa2ffee4ba8966d (diff) |
more ast_copy_string conversions
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6075 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-x | res/res_agi.c | 8 | ||||
-rwxr-xr-x | res/res_crypto.c | 6 | ||||
-rwxr-xr-x | res/res_indications.c | 12 | ||||
-rwxr-xr-x | res/res_monitor.c | 6 | ||||
-rwxr-xr-x | res/res_odbc.c | 2 | ||||
-rwxr-xr-x | res/res_osp.c | 34 |
6 files changed, 34 insertions, 34 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index 9ae23dca3..611b92cf4 100755 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -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, "|"))) { diff --git a/res/res_crypto.c b/res/res_crypto.c index 43936a297..796515ee3 100755 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -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; diff --git a/res/res_indications.c b/res/res_indications.c index 18f4072d8..b3852daf1 100755 --- a/res/res_indications.c +++ b/res/res_indications.c @@ -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); diff --git a/res/res_monitor.c b/res/res_monitor.c index 80051d582..c5d30881d 100755 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -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='-'; } diff --git a/res/res_odbc.c b/res/res_odbc.c index c670b710a..903fc972d 100755 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -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; diff --git a/res/res_osp.c b/res/res_osp.c index 3dd38d799..7d0f1e3fb 100755 --- a/res/res_osp.c +++ b/res/res_osp.c @@ -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: |