aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
commit000e0986072e528276eb7ea9a37728b5b0e6be76 (patch)
treeb186c37b5085861c464a92debbf99dd8c2b71780 /pbx
parentc3ad9c9ef53aa9d4297f7c0f009da3c33f50bebc (diff)
apparently developers are still not aware that they should be use ast_copy_string instead of strncpy... fix up many more users, and fix some bugs in the process
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46200 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r--pbx/dundi-parser.c2
-rw-r--r--pbx/pbx_ael.c33
-rw-r--r--pbx/pbx_realtime.c4
-rw-r--r--pbx/pbx_spool.c14
4 files changed, 28 insertions, 25 deletions
diff --git a/pbx/dundi-parser.c b/pbx/dundi-parser.c
index 786f0a2ac..14ef9e740 100644
--- a/pbx/dundi-parser.c
+++ b/pbx/dundi-parser.c
@@ -129,7 +129,7 @@ static void dump_string(char *output, int maxlen, void *value, int len)
maxlen--;
if (maxlen > len)
maxlen = len;
- strncpy(output,value, maxlen);
+ strncpy(output, value, maxlen);
output[maxlen] = '\0';
}
diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index b68322726..4d32e456e 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -823,13 +823,13 @@ static void check_includes(pval *includes)
static void check_timerange(pval *p)
{
- char times[200];
+ char *times;
char *e;
int s1, s2;
int e1, e2;
+ times = ast_strdupa(p->u1.str);
- strncpy(times, p->u1.str, sizeof(times));
/* Star is all times */
if (ast_strlen_zero(times) || !strcmp(times, "*")) {
return;
@@ -891,13 +891,13 @@ static char *days[] =
/*! \brief get_dow: Get day of week */
static void check_dow(pval *DOW)
{
- char dow[200];
+ char *dow;
char *c;
/* The following line is coincidence, really! */
int s, e;
- strncpy(dow,DOW->u1.str,sizeof(dow));
-
+ dow = ast_strdupa(DOW->u1.str);
+
/* Check for all days */
if (ast_strlen_zero(dow) || !strcmp(dow, "*"))
return;
@@ -930,12 +930,13 @@ static void check_dow(pval *DOW)
static void check_day(pval *DAY)
{
- char day[200];
+ char *day;
char *c;
/* The following line is coincidence, really! */
int s, e;
- strncpy(day,DAY->u1.str,sizeof(day));
+ day = ast_strdupa(DAY->u1.str);
+
/* Check for all days */
if (ast_strlen_zero(day) || !strcmp(day, "*")) {
return;
@@ -992,12 +993,13 @@ static char *months[] =
static void check_month(pval *MON)
{
- char mon[200];
+ char *mon;
char *c;
/* The following line is coincidence, really! */
int s, e;
- strncpy(mon,MON->u1.str,sizeof(mon));
+ mon = ast_strdupa(MON->u1.str);
+
/* Check for all days */
if (ast_strlen_zero(mon) || !strcmp(mon, "*"))
return ;
@@ -1876,14 +1878,14 @@ int is_empty(char *arg)
int option_matches_j( struct argdesc *should, pval *is, struct argapp *app)
{
struct argchoice *ac;
- char opcop[400],*q,*p;
+ char *opcop,*q,*p;
switch (should->dtype) {
case ARGD_OPTIONSET:
if ( strstr(is->u1.str,"${") )
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 */
if ( *q == '(' ) {
@@ -1938,7 +1940,7 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app)
int option_matches( struct argdesc *should, pval *is, struct argapp *app)
{
struct argchoice *ac;
- char opcop[400];
+ char *opcop;
switch (should->dtype) {
case ARGD_STRING:
@@ -1973,7 +1975,7 @@ int option_matches( struct argdesc *should, pval *is, struct argapp *app)
break;
case ARGD_OPTIONSET:
- strncpy(opcop,is->u1.str,sizeof(opcop));
+ opcop = ast_strdupa(is->u1.str);
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? */
@@ -2065,7 +2067,7 @@ void check_switch_expr(pval *item, struct argapp *apps)
{
#ifdef AAL_ARGCHECK
/* get and clean the variable name */
- char buff1[1024],*p;
+ char *buff1, *p;
struct argapp *a,*a2;
struct appsetvar *v,*v2;
struct argchoice *c;
@@ -2075,7 +2077,8 @@ void check_switch_expr(pval *item, struct argapp *apps)
while (p && *p && (*p == ' ' || *p == '\t' || *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'))
buff1[strlen(buff1)-1] = 0;
/* buff1 now contains the variable name */
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 31abe065f..9ee770c99 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -97,7 +97,7 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
case MODE_MATCH:
default:
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);
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) {
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"))
tmp = ast_strdupa(v->value);
}
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index ec008280b..d9b0eac6a 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -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);
#endif
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, '/'))) {
*c2 = '\0';
c2++;
- strncpy(o->dest, c2, sizeof(o->dest) - 1);
+ ast_copy_string(o->dest, c2, sizeof(o->dest));
} else {
ast_log(LOG_NOTICE, "Channel should be in form Tech/Dest at line %d of %s\n", lineno, fn);
o->tech[0] = '\0';
@@ -178,18 +178,18 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
} else if (!strcasecmp(buf, "callerid")) {
ast_callerid_split(c, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
} 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")) {
- strncpy(o->data, c, sizeof(o->data) - 1);
+ ast_copy_string(o->data, c, sizeof(o->data));
} else if (!strcasecmp(buf, "maxretries")) {
if (sscanf(c, "%d", &o->maxretries) != 1) {
ast_log(LOG_WARNING, "Invalid max retries at line %d of %s\n", lineno, fn);
o->maxretries = 0;
}
} 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")) {
- strncpy(o->exten, c, sizeof(o->exten) - 1);
+ ast_copy_string(o->exten, c, sizeof(o->exten));
} else if (!strcasecmp(buf, "priority")) {
if ((sscanf(c, "%d", &o->priority) != 1) || (o->priority < 1)) {
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);
}
}
- 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))) {
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;