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;
}
{
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;
}
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);
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, "|"))) {
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;
/* 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;
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);
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);
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;
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);
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",
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)
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='-';
}
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;
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;
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++;
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);
} 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;
}
*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 = "";
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;
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 = "";
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;
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;
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:
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: