Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv4395
Modified Files:
acl.c astmm.c callerid.c cli.c config.c enum.c frame.c
logger.c manager.c privacy.c srv.c term.c
Log Message:
more ast_copy_string conversions
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- acl.c 8 Jul 2005 14:27:39 -0000 1.47
+++ acl.c 10 Jul 2005 22:56:21 -0000 1.48
@@ -146,7 +146,7 @@
path = path->next;
}
if (ha) {
- strncpy(tmp, stuff, sizeof(tmp) - 1);
+ ast_copy_string(tmp, stuff, sizeof(tmp));
nm = strchr(tmp, '/');
if (!nm)
nm = "255.255.255.255";
@@ -248,7 +248,7 @@
struct my_ifreq ifreq;
memset(&ifreq, 0, sizeof(ifreq));
- strncpy(ifreq.ifrn_name,iface,sizeof(ifreq.ifrn_name) - 1);
+ ast_copy_string(ifreq.ifrn_name,iface,sizeof(ifreq.ifrn_name));
mysock = socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
res = ioctl(mysock,SIOCGIFADDR,&ifreq);
Index: astmm.c
===================================================================
RCS file: /usr/cvsroot/asterisk/astmm.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- astmm.c 6 Jun 2005 23:12:05 -0000 1.16
+++ astmm.c 10 Jul 2005 22:56:21 -0000 1.17
@@ -1,7 +1,7 @@
/*
* Asterisk -- A telephony toolkit for Linux.
*
- * Channel Variables
+ * Memory Management
*
* Copyright (C) 2002-2005, Mark Spencer
*
@@ -73,9 +73,9 @@
reg = malloc(size + sizeof(struct ast_region));
ast_mutex_lock(®lock);
if (reg) {
- strncpy(reg->file, file, sizeof(reg->file) - 1);
+ ast_copy_string(reg->file, file, sizeof(reg->file));
reg->file[sizeof(reg->file) - 1] = '\0';
- strncpy(reg->func, func, sizeof(reg->func) - 1);
+ ast_copy_string(reg->func, func, sizeof(reg->func));
reg->func[sizeof(reg->func) - 1] = '\0';
reg->lineno = lineno;
reg->len = size;
@@ -305,7 +305,7 @@
if (!cur) {
cur = alloca(sizeof(struct
file_summary));
memset(cur, 0, sizeof(struct
file_summary));
- strncpy(cur->fn, fn ? reg->func :
reg->file, sizeof(cur->fn) - 1);
+ ast_copy_string(cur->fn, fn ? reg->func
: reg->file, sizeof(cur->fn));
cur->next = list;
list = cur;
}
Index: callerid.c
===================================================================
RCS file: /usr/cvsroot/asterisk/callerid.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- callerid.c 6 Jun 2005 22:12:18 -0000 1.33
+++ callerid.c 10 Jul 2005 22:56:21 -0000 1.34
@@ -364,7 +364,7 @@
}
} else {
/* SDMF */
- strncpy(cid->number, cid->rawdata + 8,
sizeof(cid->number)-1);
+ ast_copy_string(cid->number,
cid->rawdata + 8, sizeof(cid->number));
}
/* Update flags */
cid->flags = 0;
@@ -646,7 +646,7 @@
return 0;
}
} else {
- strncpy(tmp, instr, sizeof(tmp)-1);
+ ast_copy_string(tmp, instr, sizeof(tmp));
ast_shrink_phone_number(tmp);
if (ast_isphonenumber(tmp)) {
/* Assume it's just a location */
@@ -691,11 +691,11 @@
if (name && num)
snprintf(buf, bufsiz, "\"%s\" <%s>", name, num);
else if (name)
- strncpy(buf, name, bufsiz - 1);
+ ast_copy_string(buf, name, bufsiz);
else if (num)
- strncpy(buf, num, bufsiz - 1);
+ ast_copy_string(buf, num, bufsiz);
else
- strncpy(buf, unknown, bufsiz - 1);
+ ast_copy_string(buf, unknown, bufsiz);
return buf;
}
int ast_callerid_split(const char *buf, char *name, int namelen, char *num,
int numlen)
@@ -710,12 +710,12 @@
}
ast_callerid_parse(tmp, &n, &l);
if (n)
- strncpy(name, n, namelen - 1);
+ ast_copy_string(name, n, namelen);
else
name[0] = '\0';
if (l) {
ast_shrink_phone_number(l);
- strncpy(num, l, numlen - 1);
+ ast_copy_string(num, l, numlen);
} else
num[0] = '\0';
return 0;
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- cli.c 7 Jul 2005 22:32:20 -0000 1.89
+++ cli.c 10 Jul 2005 22:56:21 -0000 1.90
@@ -587,7 +587,7 @@
option_debug = newlevel;
if (argc == 4) {
filename = argv[3];
- strncpy(debug_filename, filename, sizeof(debug_filename) - 1);
+ ast_copy_string(debug_filename, filename,
sizeof(debug_filename));
} else {
debug_filename[0] = '\0';
}
@@ -686,7 +686,7 @@
sec = elapsed_seconds % 60;
snprintf(cdrtime, sizeof(cdrtime), "%dh%dm%ds", hour, min, sec);
} else
- strncpy(cdrtime, "N/A", sizeof(cdrtime) -1);
+ strcpy(cdrtime, "N/A");
ast_cli(fd,
" -- General --\n"
" Name: %s\n"
@@ -784,7 +784,7 @@
if (pos != 1)
return NULL;
if (word[0] == '/')
- strncpy(filename, word, sizeof(filename)-1);
+ ast_copy_string(filename, word, sizeof(filename));
else
snprintf(filename, sizeof(filename), "%s/%s", (char
*)ast_config_AST_MODULE_DIR, word);
c = (char*)filename_completion_function(filename, state);
Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- config.c 5 Jul 2005 22:11:42 -0000 1.72
+++ config.c 10 Jul 2005 22:56:21 -0000 1.73
@@ -192,7 +192,7 @@
category = malloc(sizeof(struct ast_category));
if (category) {
memset(category, 0, sizeof(struct ast_category));
- strncpy(category->name, name, sizeof(category->name) - 1);
+ ast_copy_string(category->name, name, sizeof(category->name));
}
return category;
@@ -295,7 +295,7 @@
void ast_category_rename(struct ast_category *cat, const char *name)
{
- strncpy(cat->name, name, sizeof(cat->name) - 1);
+ ast_copy_string(cat->name, name, sizeof(cat->name));
}
static void inherit_category(struct ast_category *new, const struct
ast_category *base)
@@ -531,7 +531,7 @@
cat = ast_config_get_current_category(cfg);
if (filename[0] == '/') {
- strncpy(fn, filename, sizeof(fn)-1);
+ ast_copy_string(fn, filename, sizeof(fn));
} else {
snprintf(fn, sizeof(fn), "%s/%s", (char
*)ast_config_AST_CONFIG_DIR, filename);
}
@@ -556,7 +556,7 @@
/* loop over expanded files */
int i;
for (i=0; i<globbuf.gl_pathc; i++) {
- strncpy(fn, globbuf.gl_pathv[i], sizeof(fn)-1);
+ ast_copy_string(fn, globbuf.gl_pathv[i],
sizeof(fn));
#endif
if ((option_verbose > 1) && !option_debug) {
ast_verbose( VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
@@ -668,7 +668,7 @@
snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR,
configfile);
}
time(&t);
- strncpy(date, ctime(&t), sizeof(date) - 1);
+ ast_copy_string(date, ctime(&t), sizeof(date));
if ((f = fopen(fn, "w"))) {
if ((option_verbose > 1) && !option_debug)
ast_verbose( VERBOSE_PREFIX_2 "Saving '%s': ", fn);
Index: enum.c
===================================================================
RCS file: /usr/cvsroot/asterisk/enum.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- enum.c 6 Jun 2005 22:12:18 -0000 1.27
+++ enum.c 10 Jul 2005 22:56:21 -0000 1.28
@@ -148,23 +148,23 @@
if ((!strncasecmp(services, "e2u+sip", 7)) ||
(!strncasecmp(services, "sip+e2u", 7))) {
- strncpy(tech, "sip", techsize -1);
+ ast_copy_string(tech, "sip", techsize);
} else if ((!strncasecmp(services, "e2u+h323", 8)) ||
(!strncasecmp(services, "h323+e2u", 8))) {
- strncpy(tech, "h323", techsize -1);
+ ast_copy_string(tech, "h323", techsize);
} else if ((!strncasecmp(services, "e2u+x-iax2", 10)) ||
(!strncasecmp(services, "e2u+iax2", 8)) ||
(!strncasecmp(services, "iax2+e2u", 8))) {
- strncpy(tech, "iax2", techsize -1);
+ ast_copy_string(tech, "iax2", techsize);
} else if ((!strncasecmp(services, "e2u+x-iax", 9)) ||
(!strncasecmp(services, "e2u+iax", 7)) ||
(!strncasecmp(services, "iax+e2u", 7))) {
- strncpy(tech, "iax", techsize -1);
+ ast_copy_string(tech, "iax", techsize);
} else if ((!strncasecmp(services, "e2u+tel", 7)) ||
(!strncasecmp(services, "tel+e2u", 7))) {
- strncpy(tech, "tel", techsize -1);
+ ast_copy_string(tech, "tel", techsize);
} else if (!strncasecmp(services, "e2u+voice:", 10)) {
- strncpy(tech, services+10, techsize -1);
+ ast_copy_string(tech, services+10, techsize);
} else {
ast_log(LOG_DEBUG,
"Services must be e2u+${tech}, ${tech}+e2u, or e2u+voice: where
$tech is from (sip, h323, tel, iax, iax2). \n");
@@ -172,7 +172,7 @@
}
/* DEDBUGGING STUB
- strncpy(regexp, "!^\\+43(.*)[EMAIL PROTECTED]", sizeof(regexp) - 1);
+ ast_copy_string(regexp, "!^\\+43(.*)[EMAIL PROTECTED]", sizeof(regexp)
- 1);
*/
regexp_len = strlen(regexp);
@@ -244,7 +244,7 @@
}
}
*d = 0;
- strncpy(dst, temp, dstsize - 1);
+ ast_copy_string(dst, temp, dstsize);
dst[dstsize - 1] = '\0';
return 0;
}
@@ -286,7 +286,7 @@
len +=1;
/* finally, copy the answer into c->txt */
- strncpy(c->txt, answer, len < c->txtlen ? len-1 : (c->txtlen)-1);
+ ast_copy_string(c->txt, answer, len < c->txtlen ? len : (c->txtlen));
/* just to be safe, let's make sure c->txt is null terminated */
c->txt[(c->txtlen)-1] = '\0';
@@ -439,7 +439,7 @@
tmp = malloc(sizeof(struct enum_search));
if (tmp) {
memset(tmp, 0, sizeof(struct enum_search));
- strncpy(tmp->toplev, s, sizeof(tmp->toplev) - 1);
+ ast_copy_string(tmp->toplev, s, sizeof(tmp->toplev));
}
return tmp;
}
Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- frame.c 6 Jun 2005 22:12:18 -0000 1.58
+++ frame.c 10 Jul 2005 22:56:21 -0000 1.59
@@ -739,7 +739,7 @@
case AST_FRAME_TEXT:
strcpy(ftype, "Text");
strcpy(subclass, "N/A");
- strncpy(moreinfo, f->data, sizeof(moreinfo) - 1);
+ ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
break;
case AST_FRAME_IMAGE:
strcpy(ftype, "Image");
@@ -750,7 +750,7 @@
switch(f->subclass) {
case AST_HTML_URL:
strcpy(subclass, "URL");
- strncpy(moreinfo, f->data, sizeof(moreinfo) - 1);
+ ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
break;
case AST_HTML_DATA:
strcpy(subclass, "Data");
@@ -769,7 +769,7 @@
break;
case AST_HTML_LINKURL:
strcpy(subclass, "Link URL");
- strncpy(moreinfo, f->data, sizeof(moreinfo) - 1);
+ ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
break;
case AST_HTML_UNLINK:
strcpy(subclass, "Unlink");
Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- logger.c 5 Jul 2005 20:31:34 -0000 1.76
+++ logger.c 10 Jul 2005 22:56:21 -0000 1.77
@@ -245,7 +245,7 @@
if(!ast_strlen_zero(hostname)) {
snprintf(chan->filename, sizeof(chan->filename)
- 1,"%s.%s", channel, hostname);
} else {
- strncpy(chan->filename, channel,
sizeof(chan->filename) - 1);
+ ast_copy_string(chan->filename, channel,
sizeof(chan->filename));
}
}
@@ -297,7 +297,7 @@
if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
if(ast_true(s)) {
if(gethostname(hostname, sizeof(hostname)-1)) {
- strncpy(hostname, "unknown",
sizeof(hostname)-1);
+ ast_copy_string(hostname, "unknown",
sizeof(hostname));
ast_log(LOG_WARNING, "What box has no
hostname???\n");
}
} else
@@ -305,9 +305,9 @@
} else
hostname[0] = '\0';
if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
- strncpy(dateformat, s, sizeof(dateformat) - 1);
+ ast_copy_string(dateformat, s, sizeof(dateformat));
} else
- strncpy(dateformat, "%b %e %T", sizeof(dateformat) - 1);
+ ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
logfiles.queue_log = ast_true(s);
}
@@ -417,7 +417,7 @@
fclose(f->fileptr); /* Close file */
f->fileptr = NULL;
if(rotate) {
- strncpy(old, f->filename, sizeof(old) - 1);
+ ast_copy_string(old, f->filename, sizeof(old));
for(x=0;;x++) {
snprintf(new, sizeof(new), "%s.%d",
f->filename, x);
Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- manager.c 9 Jun 2005 19:27:19 -0000 1.101
+++ manager.c 10 Jul 2005 22:56:21 -0000 1.102
@@ -135,7 +135,7 @@
}
}
if (ast_strlen_zero(res)) {
- strncpy(res, "<none>", reslen);
+ ast_copy_string(res, "<none>", reslen);
}
return res;
}
@@ -480,7 +480,7 @@
cat = ast_category_browse(cfg, cat);
}
if (cat) {
- strncpy(s->username, cat, sizeof(s->username) - 1);
+ ast_copy_string(s->username, cat, sizeof(s->username));
s->readperm = get_perm(ast_variable_retrieve(cfg, cat, "read"));
s->writeperm = get_perm(ast_variable_retrieve(cfg, cat,
"write"));
ast_config_destroy(cfg);
@@ -953,7 +953,7 @@
astman_send_error(s, m, "Invalid timeout\n");
return 0;
}
- strncpy(tmp, name, sizeof(tmp) - 1);
+ ast_copy_string(tmp, name, sizeof(tmp));
tech = tmp;
data = strchr(tmp, '/');
if (!data) {
@@ -962,7 +962,7 @@
}
*data = '\0';
data++;
- strncpy(tmp2, callerid, sizeof(tmp2) - 1);
+ ast_copy_string(tmp2, callerid, sizeof(tmp2));
ast_callerid_parse(tmp2, &n, &l);
if (n) {
if (ast_strlen_zero(n))
@@ -981,18 +981,18 @@
memset(fast, 0, sizeof(struct fast_originate_helper));
if (id && !ast_strlen_zero(id))
snprintf(fast->idtext, sizeof(fast->idtext),
"ActionID: %s\r\n", id);
- strncpy(fast->tech, tech, sizeof(fast->tech) - 1);
- strncpy(fast->data, data, sizeof(fast->data) - 1);
- strncpy(fast->app, app, sizeof(fast->app) - 1);
- strncpy(fast->appdata, appdata, sizeof(fast->appdata) -
1);
+ ast_copy_string(fast->tech, tech, sizeof(fast->tech));
+ ast_copy_string(fast->data, data, sizeof(fast->data));
+ ast_copy_string(fast->app, app, sizeof(fast->app));
+ ast_copy_string(fast->appdata, appdata,
sizeof(fast->appdata));
if (l)
- strncpy(fast->cid_num, l, sizeof(fast->cid_num)
- 1);
+ ast_copy_string(fast->cid_num, l,
sizeof(fast->cid_num));
if (n)
- strncpy(fast->cid_name, n,
sizeof(fast->cid_name) - 1);
- strncpy(fast->variable, variable,
sizeof(fast->variable) - 1);
- strncpy(fast->account, account, sizeof(fast->account) -
1);
- strncpy(fast->context, context, sizeof(fast->context) -
1);
- strncpy(fast->exten, exten, sizeof(fast->exten) - 1);
+ ast_copy_string(fast->cid_name, n,
sizeof(fast->cid_name));
+ ast_copy_string(fast->variable, variable,
sizeof(fast->variable));
+ ast_copy_string(fast->account, account,
sizeof(fast->account));
+ ast_copy_string(fast->context, context,
sizeof(fast->context));
+ ast_copy_string(fast->exten, exten,
sizeof(fast->exten));
fast->timeout = to;
fast->priority = pi;
pthread_attr_init(&attr);
@@ -1173,7 +1173,7 @@
char idText[256] = "";
char iabuf[INET_ADDRSTRLEN];
- strncpy(action, astman_get_header(m, "Action"), sizeof(action) - 1);
+ ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action));
ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
if (ast_strlen_zero(action)) {
Index: privacy.c
===================================================================
RCS file: /usr/cvsroot/asterisk/privacy.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- privacy.c 6 Jun 2005 22:12:18 -0000 1.6
+++ privacy.c 10 Jul 2005 22:56:21 -0000 1.7
@@ -1,11 +1,11 @@
/*
* Asterisk -- A telephony toolkit for Linux.
*
- * Channel Management
+ * Privacy Routines
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999 - 2005, Mark Spencer
*
- * Mark Spencer <[EMAIL PROTECTED]>
+ * Mark Spencer <[EMAIL PROTECTED]>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -44,7 +44,7 @@
int res;
char key[256], result[256];
if (cid)
- strncpy(tmp, cid, sizeof(tmp) - 1);
+ ast_copy_string(tmp, cid, sizeof(tmp));
ast_callerid_parse(tmp, &n, &l);
if (l) {
ast_shrink_phone_number(l);
@@ -80,7 +80,7 @@
int res;
char key[256];
if (cid)
- strncpy(tmp, cid, sizeof(tmp) - 1);
+ ast_copy_string(tmp, cid, sizeof(tmp));
ast_callerid_parse(tmp, &n, &l);
if (l) {
ast_shrink_phone_number(l);
Index: srv.c
===================================================================
RCS file: /usr/cvsroot/asterisk/srv.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- srv.c 6 Jun 2005 22:12:18 -0000 1.14
+++ srv.c 10 Jul 2005 22:56:21 -0000 1.15
@@ -65,7 +65,7 @@
if (option_verbose > 3)
ast_verbose( VERBOSE_PREFIX_3 "parse_srv: SRV mapped to
host %s, port %d\n", repl, ntohs(srv->portnum));
if (host) {
- strncpy(host, repl, hostlen - 1);
+ ast_copy_string(host, repl, hostlen);
host[hostlen-1] = '\0';
}
if (portno)
Index: term.c
===================================================================
RCS file: /usr/cvsroot/asterisk/term.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- term.c 6 Jun 2005 22:12:18 -0000 1.11
+++ term.c 10 Jul 2005 22:56:21 -0000 1.12
@@ -1,11 +1,11 @@
/*
* Asterisk -- A telephony toolkit for Linux.
*
- * Channel Management
+ * Terminal Routines
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999 - 2005, Mark Spencer
*
- * Mark Spencer <[EMAIL PROTECTED]>
+ * Mark Spencer <[EMAIL PROTECTED]>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -140,16 +140,16 @@
int attr=0;
char tmp[40];
if (!vt100compat) {
- strncpy(outbuf, inbuf, maxout -1);
+ ast_copy_string(outbuf, inbuf, maxout);
return outbuf;
}
if (!fgcolor && !bgcolor) {
- strncpy(outbuf, inbuf, maxout - 1);
+ ast_copy_string(outbuf, inbuf, maxout);
return outbuf;
}
if ((fgcolor & 128) && (bgcolor & 128)) {
/* Can't both be highlighted */
- strncpy(outbuf, inbuf, maxout - 1);
+ ast_copy_string(outbuf, inbuf, maxout);
return outbuf;
}
if (!bgcolor)
@@ -241,7 +241,7 @@
char *term_prompt(char *outbuf, const char *inbuf, int maxout)
{
if (!vt100compat) {
- strncpy(outbuf, inbuf, maxout -1);
+ ast_copy_string(outbuf, inbuf, maxout);
return outbuf;
}
snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s",
_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs