aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-07-14 13:57:15 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-07-14 13:57:15 +0000
commit5d8654361451b217b1fc604f449554e74a11b70b (patch)
tree30a1118273807f5c6ba0e3ca611ab0c6a160fa3b /res
parent3aea726c3943cf31d2d90c194d1e126891b1481d (diff)
Merge remaining audit patch (save dlfcn.c)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3436 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-xres/res_adsi.c13
-rwxr-xr-xres/res_config_odbc.c18
-rwxr-xr-xres/res_crypto.c8
-rwxr-xr-xres/res_indications.c6
-rwxr-xr-xres/res_musiconhold.c4
-rwxr-xr-xres/res_odbc.c2
-rwxr-xr-xres/res_osp.c34
7 files changed, 43 insertions, 42 deletions
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 1e198b7ae..2ee440e6a 100755
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -1006,13 +1006,13 @@ static void init_state(void)
for (x=0;x<ADSI_MAX_INTRO;x++)
aligns[x] = ADSI_JUST_CENT;
- strcpy(intro[0], "Welcome to the");
- strcpy(intro[1], "Asterisk");
- strcpy(intro[2], "Open Source PBX");
+ strncpy(intro[0], "Welcome to the", sizeof(intro[0]) - 1);
+ strncpy(intro[1], "Asterisk", sizeof(intro[1]) - 1);
+ strncpy(intro[2], "Open Source PBX", sizeof(intro[2]) - 1);
total = 3;
speeds = 0;
for (x=3;x<ADSI_MAX_INTRO;x++)
- strcpy(intro[x], "");
+ intro[x][0] = '\0';
memset(speeddial, 0, sizeof(speeddial));
alignment = ADSI_JUST_CENT;
}
@@ -1034,7 +1034,8 @@ static void adsi_load(void)
else if (!strcasecmp(v->name, "greeting")) {
if (x < ADSI_MAX_INTRO) {
aligns[x] = alignment;
- strncpy(intro[x], v->value, 20);
+ strncpy(intro[x], v->value, sizeof(intro[x]) - 1);
+ intro[x][sizeof(intro[x]) - 1] = '\0';
x++;
}
} else if (!strcasecmp(v->name, "maxretries")) {
@@ -1056,7 +1057,7 @@ static void adsi_load(void)
sname = name;
if (x < ADSI_MAX_SPEED_DIAL) {
/* Up to 20 digits */
- strncpy(speeddial[x][0], v->name, 20);
+ strncpy(speeddial[x][0], v->name, sizeof(speeddial[x][0]) - 1);
strncpy(speeddial[x][1], name, 18);
strncpy(speeddial[x][2], sname, 7);
x++;
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 68779eec6..1d5cb8d51 100755
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -38,16 +38,16 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
struct ast_config *config, *new;
struct ast_variable *v, *cur_v, *new_v;
struct ast_category *cur_cat, *new_cat;
- char table[128];
- char connection[128];
+ char table[128] = "";
+ char connection[128] = "";
int configured = 0, res = 0;
odbc_obj *obj;
SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0;
SQLBIGINT id;
- char sql[255], filename[128], category[128], var_name[128], var_val[128];
+ char sql[255] = "", filename[128], category[128], var_name[128], var_val[128];
SQLSMALLINT rowcount=0;
SQLHSTMT stmt;
- char last[80];
+ char last[80] = "";
int cat_started = 0;
int var_started = 0;
@@ -68,10 +68,10 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
if (config) {
for (v = ast_variable_browse (config, "settings"); v; v = v->next) {
if (!strcmp (v->name, "table")) {
- strncpy (table, v->value, sizeof (table));
+ strncpy(table, v->value, sizeof(table) - 1);
configured++;
} else if (!strcmp (v->name, "connection")) {
- strncpy (connection, v->value, sizeof (connection));
+ strncpy(connection, v->value, sizeof(connection) - 1);
configured++;
}
}
@@ -96,7 +96,7 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
SQLBindCol (stmt, 7, SQL_C_CHAR, &var_name, sizeof (var_name), &err);
SQLBindCol (stmt, 8, SQL_C_CHAR, &var_val, sizeof (var_val), &err);
- sprintf (sql, "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file);
+ snprintf(sql, sizeof(sql), "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file);
res = SQLExecDirect (stmt, sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -133,7 +133,7 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
);
} else {
if (strcmp (last, category) || last_cat_metric != cat_metric) {
- strcpy (last, category);
+ strncpy(last, category, sizeof(last) - 1);
last_cat_metric = cat_metric;
new_cat = (struct ast_category *) ast_new_category (category);
@@ -184,7 +184,7 @@ int unload_module (void)
int load_module (void)
{
memset (&reg1, 0, sizeof (struct ast_config_reg));
- strcpy (reg1.name, "odbc");
+ strncpy(reg1.name, "odbc", sizeof(reg1.name) - 1);
reg1.func = config_odbc;
ast_cust_config_register (&reg1);
ast_log (LOG_NOTICE, "res_config_odbc loaded.\n");
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 8df8d2b4c..706171590 100755
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -213,9 +213,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));
+ strncpy(key->fn, ffname, sizeof(key->fn) - 1);
/* Then the name */
- strncpy(key->name, fname, sizeof(key->name));
+ strncpy(key->name, fname, sizeof(key->name) - 1);
key->ktype = ktype;
/* Yes, assume we're going to be deleted */
key->delme = 1;
@@ -444,14 +444,14 @@ static int init_keys(int fd, int argc, char *argv[])
struct ast_key *key;
int ign;
char *kn;
- char tmp[256];
+ char tmp[256] = "";
key = keys;
while(key) {
/* 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));
+ strncpy(tmp, kn, sizeof(tmp) - 1);
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 f3bbc01ba..b289612d5 100755
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -163,7 +163,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);
+ strncpy(buf+j,"\n",sizeof(buf)-j-1);
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);
@@ -241,7 +241,7 @@ static int ind_load_module(void)
return -1;
}
memset(tones,0,sizeof(struct tone_zone));
- strncpy(tones->country,cxt,sizeof(tones->country));
+ strncpy(tones->country,cxt,sizeof(tones->country) - 1);
v = ast_variable_browse(cfg, cxt);
while(v) {
@@ -282,7 +282,7 @@ static int ind_load_module(void)
return -1;
}
memset(azone,0,sizeof(struct tone_zone));
- strncpy(azone->country,country,sizeof(azone->country));
+ strncpy(azone->country, country, sizeof(azone->country) - 1);
strncpy(azone->alias, cxt, sizeof(azone->alias)-1);
if (ast_register_indication_country(azone)) {
ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 311cb4046..b446551c1 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -153,7 +153,7 @@ static int spawn_mp3(struct mohclass *class)
files = 0;
while((de = readdir(dir)) && (files < MAX_MP3S)) {
if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) {
- strncpy(fns[files], de->d_name, sizeof(fns[files]));
+ strncpy(fns[files], de->d_name, sizeof(fns[files]) - 1);
argv[argc++] = fns[files];
files++;
}
@@ -340,7 +340,7 @@ static int moh2_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "SetMusicOnHold requires an argument (class)\n");
return -1;
}
- strncpy(chan->musicclass, data, sizeof(chan->musicclass));
+ strncpy(chan->musicclass, data, sizeof(chan->musicclass) - 1);
return 0;
}
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 354d7f836..c8efb0620 100755
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -61,7 +61,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));
+ strncpy(registry[x].name, name, sizeof(registry[x].name) - 1);
registry[x].obj = obj;
registry[x].used = 1;
return 1;
diff --git a/res/res_osp.c b/res/res_osp.c
index 5db3d42e0..7945c08ad 100755
--- a/res/res_osp.c
+++ b/res/res_osp.c
@@ -121,7 +121,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
osp->retrydelay = OSP_DEFAULT_RETRY_DELAY;
osp->retrylimit = OSP_DEFAULT_RETRY_LIMIT;
osp->timeout = OSP_DEFAULT_TIMEOUT;
- strcpy(osp->source, "");
+ osp->source[0] = '\0';
ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat);
v = ast_variable_browse(cfg, cat);
while(v) {
@@ -138,7 +138,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
} 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]));
+ strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]) - 1);
else
snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), AST_KEY_DIR "/%s", v->value);
osp->cacount++;
@@ -146,7 +146,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]));
+ strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]) - 1);
osp->spcount++;
} else
ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno);
@@ -424,7 +424,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
{
char tmp[256]="", *l, *n;
char iabuf[INET_ADDRSTRLEN];
- char source[OSP_MAX]; /* Same length as osp->source */
+ char source[OSP_MAX] = ""; /* Same length as osp->source */
char *token2;
int tokenlen;
struct osp_provider *osp;
@@ -459,7 +459,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 {
- strcpy(source, osp->source);
+ strncpy(source, osp->source, sizeof(source) - 1);
res = 1;
}
break;
@@ -491,7 +491,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
unsigned int timelimit;
unsigned int callidlen;
struct osp_provider *osp;
- char source[OSP_MAX]; /* Same length as osp->source */
+ char source[OSP_MAX] = ""; /* Same length as osp->source */
char uniqueid[32] = "";
char callednum[2048]="";
char destination[2048]="";
@@ -502,9 +502,9 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
result->handle = -1;
result->numresults = 0;
- strcpy(result->tech, "");
- strcpy(result->dest, "");
- strcpy(result->token, "");
+ result->tech[0] = '\0';
+ result->dest[0] = '\0';
+ result->token[0] = '\0';
if (!provider || !strlen(provider))
provider = "default";
@@ -535,7 +535,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 {
- strcpy(source, osp->source);
+ strncpy(source, osp->source, sizeof(source) - 1);
res = 1;
}
break;
@@ -568,11 +568,11 @@ 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:
- strcpy(result->tech, "H323");
+ strncpy(result->tech, "H323", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break;
case OSPE_DEST_PROT_SIP:
- strcpy(result->tech, "SIP");
+ strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break;
default:
@@ -626,9 +626,9 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
char token[2000];
OSPE_DEST_PROT prot;
- strcpy(result->tech, "");
- strcpy(result->dest, "");
- strcpy(result->token, "");
+ result->tech[0] = '\0';
+ result->dest[0] = '\0';
+ result->token[0] = '\0';
if (result->handle > -1) {
dummy = 0;
@@ -646,11 +646,11 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
destination[strlen(destination) - 1] = '\0';
switch(prot) {
case OSPE_DEST_PROT_H323_SETUP:
- strcpy(result->tech, "H323");
+ strncpy(result->tech, "H323", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break;
case OSPE_DEST_PROT_SIP:
- strcpy(result->tech, "SIP");
+ strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break;
default: