Index: acl.c =================================================================== RCS file: /usr/cvsroot/asterisk/acl.c,v retrieving revision 1.54 diff -u -r1.54 acl.c --- acl.c 14 Aug 2005 03:16:06 -0000 1.54 +++ acl.c 6 Sep 2005 00:37:36 -0000 @@ -127,7 +127,7 @@ { struct ast_ha *ha = malloc(sizeof(struct ast_ha)); char *nm = "255.255.255.255"; - char tmp[256] = ""; + char tmp[256]; struct ast_ha *prev = NULL; struct ast_ha *ret; int x, z; Index: app.c =================================================================== RCS file: /usr/cvsroot/asterisk/app.c,v retrieving revision 1.73 diff -u -r1.73 app.c --- app.c 30 Aug 2005 02:12:09 -0000 1.73 +++ app.c 6 Sep 2005 00:37:37 -0000 @@ -261,8 +261,8 @@ int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between) { - char *ptr=NULL; - int res=0; + char *ptr; + int res = 0; struct ast_frame f; if (!between) between = 100; @@ -378,7 +378,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride) { struct linear_state *lin; - char tmpf[256] = ""; + char tmpf[256]; int res = -1; int autoclose = 0; if (fd < 0) { @@ -411,11 +411,11 @@ const char *stop, const char *pause, const char *restart, int skipms) { - long elapsed = 0,last_elapsed =0; - char *breaks=NULL; - char *end=NULL; - int blen=2; - int res=0; + long elapsed = 0, last_elapsed = 0; + char *breaks = NULL; + char *end = NULL; + int blen = 2; + int res; if (stop) blen += strlen(stop); @@ -440,7 +440,6 @@ if (chan) ast_stopstream(chan); - if (file) { if ((end = strchr(file,':'))) { if (!strcasecmp(end, ":end")) { @@ -985,7 +984,7 @@ int ast_app_group_split_group(char *data, char *group, int group_max, char *category, int category_max) { int res=0; - char tmp[256] = ""; + char tmp[256]; char *grp=NULL, *cat=NULL; if (data && !ast_strlen_zero(data)) { @@ -1030,7 +1029,7 @@ struct ast_channel *chan; int count = 0; char *test; - char cat[80] = ""; + char cat[80]; char *s; if (group == NULL || ast_strlen_zero(group)) @@ -1056,7 +1055,7 @@ struct ast_channel *chan; int count = 0; char *test; - char cat[80] = ""; + char cat[80]; char *s; if (!groupmatch || ast_strlen_zero(groupmatch)) Index: file.c =================================================================== RCS file: /usr/cvsroot/asterisk/file.c,v retrieving revision 1.74 diff -u -r1.74 file.c --- file.c 30 Aug 2005 02:12:09 -0000 1.74 +++ file.c 6 Sep 2005 00:37:37 -0000 @@ -464,7 +464,7 @@ int fd = -1; int fmts = -1; char filename2[256]=""; - char filename3[256]=""; + char filename3[256]; char *endpart; int res; @@ -1149,7 +1149,7 @@ /* XXX Maybe I should just front-end ast_waitstream_full ? XXX */ int res; struct ast_frame *fr; - char exten[AST_MAX_EXTENSION] = ""; + char exten[AST_MAX_EXTENSION]; if (!context) context = c->context; while(c->stream) { Index: pbx.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx.c,v retrieving revision 1.271 diff -u -r1.271 pbx.c --- pbx.c 2 Sep 2005 18:07:26 -0000 1.271 +++ pbx.c 6 Sep 2005 00:37:40 -0000 @@ -902,7 +902,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp) { char *first,*second; - char tmpvar[80] = ""; + char tmpvar[80]; time_t thistime; struct tm brokentime; int offset,offset2; @@ -5362,7 +5362,7 @@ static int pbx_builtin_prefix(struct ast_channel *chan, void *data) { - char newexten[AST_MAX_EXTENSION] = ""; + char newexten[AST_MAX_EXTENSION]; if (!data || ast_strlen_zero(data)) { ast_log(LOG_DEBUG, "Ignoring, since there is no prefix to add\n"); @@ -5377,7 +5377,7 @@ static int pbx_builtin_suffix(struct ast_channel *chan, void *data) { - char newexten[AST_MAX_EXTENSION] = ""; + char newexten[AST_MAX_EXTENSION]; if (!data || ast_strlen_zero(data)) { ast_log(LOG_DEBUG, "Ignoring, since there is no suffix to add\n"); Index: apps/app_dial.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v retrieving revision 1.164 diff -u -r1.164 app_dial.c --- apps/app_dial.c 30 Aug 2005 02:12:09 -0000 1.164 +++ apps/app_dial.c 6 Sep 2005 00:37:43 -0000 @@ -347,7 +347,7 @@ } } else if (o->chan && (o->chan == winner)) { if (!ast_strlen_zero(o->chan->call_forward)) { - char tmpchan[256]=""; + char tmpchan[256]; char *stuff; char *tech; ast_copy_string(tmpchan, o->chan->call_forward, sizeof(tmpchan)); @@ -626,8 +626,8 @@ int res=-1; struct localuser *u; char *info, *peers, *timeout, *tech, *number, *rest, *cur; - char privdb[256] = "", *s; - char privcid[256] = ""; + char privdb[256], *s; + char privcid[256]; char privintro[1024]; char announcemsg[256] = "", *ann; struct localuser *outgoing=NULL, *tmp; @@ -668,7 +668,7 @@ char *dtmfcalled=NULL, *dtmfcalling=NULL; char *stack,*var; char *mac = NULL, *macroname = NULL; - char status[256]=""; + char status[256]; char toast[80]; int play_to_caller=0,play_to_callee=0; int playargs=0, sentringing=0, moh=0; @@ -1105,7 +1105,7 @@ } pbx_builtin_setvar_helper(tmp->chan, "DIALEDPEERNUMBER", numsubst); if (!ast_strlen_zero(tmp->chan->call_forward)) { - char tmpchan[256]=""; + char tmpchan[256]; char *stuff; char *tech; ast_copy_string(tmpchan, tmp->chan->call_forward, sizeof(tmpchan)); Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.340 diff -u -r1.340 chan_iax2.c --- channels/chan_iax2.c 2 Sep 2005 19:17:19 -0000 1.340 +++ channels/chan_iax2.c 6 Sep 2005 00:37:52 -0000 @@ -1851,7 +1851,7 @@ /*--- iax2_show_peer: Show one peer in detail ---*/ static int iax2_show_peer(int fd, int argc, char *argv[]) { - char status[30] = ""; + char status[30]; char cbuf[256]; char iabuf[INET_ADDRSTRLEN]; struct iax2_peer *peer; @@ -1961,7 +1961,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[]) { struct iax2_dpcache *dp; - char tmp[1024] = "", *pc; + char tmp[1024], *pc; int s; int x,y; struct timeval tv; @@ -3233,7 +3233,7 @@ { unsigned short callno = PTR_TO_CALLNO(c->tech_pvt); struct iax_ie_data ied; - char tmp[256] = "", *context; + char tmp[256], *context; ast_copy_string(tmp, dest, sizeof(tmp)); context = strchr(tmp, '@'); if (context) { @@ -4011,7 +4011,7 @@ #define FORMAT2 "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n" struct iax2_user *user; - char auth[90] = ""; + char auth[90]; char *pstr = ""; switch (argc) { @@ -4076,7 +4076,7 @@ #define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s\n" struct iax2_peer *peer; - char name[256] = ""; + char name[256]; char iabuf[INET_ADDRSTRLEN]; int registeredonly=0; @@ -4117,8 +4117,8 @@ ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status"); for (peer = peerl.peers;peer;peer = peer->next) { char nm[20]; - char status[20] = ""; - char srch[2000] = ""; + char status[20]; + char srch[2000]; if (registeredonly && !peer->addr.sin_addr.s_addr) continue; @@ -4251,7 +4251,7 @@ #define FORMAT "%-20.20s %-10.10s %-20.20s %8d %s\n" struct iax2_registry *reg; char host[80]; - char perceived[80] = ""; + char perceived[80]; char iabuf[INET_ADDRSTRLEN]; if (argc != 3) return RESULT_SHOWUSAGE; @@ -4840,7 +4840,7 @@ static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies) { - char requeststr[256] = ""; + char requeststr[256]; char md5secret[256] = ""; char secret[256] = ""; char rsasecret[256] = ""; @@ -4858,7 +4858,7 @@ if ((p->authmethods & IAX_AUTH_RSA) && !ast_strlen_zero(rsasecret) && !ast_strlen_zero(p->inkeys)) { struct ast_key *key; char *keyn; - char tmpkey[256] = ""; + char tmpkey[256]; char *stringp=NULL; ast_copy_string(tmpkey, p->inkeys, sizeof(tmpkey)); stringp=tmpkey; @@ -4962,7 +4962,7 @@ /* Check secret against what we have on file */ if (!ast_strlen_zero(rsasecret) && (p->authmethods & IAX_AUTH_RSA) && !ast_strlen_zero(iaxs[callno]->challenge)) { if (!ast_strlen_zero(p->inkeys)) { - char tmpkeys[256] = ""; + char tmpkeys[256]; char *stringp=NULL; ast_copy_string(tmpkeys, p->inkeys, sizeof(tmpkeys)); stringp=tmpkeys; @@ -5079,7 +5079,7 @@ if ((authmethods & IAX_AUTH_MD5) && !ast_strlen_zero(challenge)) { struct MD5Context md5; unsigned char digest[16]; - char digres[128] = ""; + char digres[128]; MD5Init(&md5); MD5Update(&md5, (unsigned char *)challenge, strlen(challenge)); MD5Update(&md5, (unsigned char *)secret, strlen(secret)); @@ -5164,7 +5164,7 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies) { int newcall = 0; - char newip[256] = ""; + char newip[256]; struct iax_ie_data ied; struct sockaddr_in new; @@ -5310,7 +5310,7 @@ struct iax2_registry *reg; /* Start pessimistic */ char peer[256] = ""; - char msgstatus[40] = ""; + char msgstatus[40]; int refresh = 0; char ourip[256] = ""; struct sockaddr_in oldus; @@ -5423,7 +5423,7 @@ static void register_peer_exten(struct iax2_peer *peer, int onoff) { - char multi[256]=""; + char multi[256]; char *stringp, *ext; if (!ast_strlen_zero(regcontext)) { ast_copy_string(multi, ast_strlen_zero(peer->regexten) ? peer->name : peer->regexten, sizeof(multi)); @@ -9087,7 +9087,7 @@ struct iax2_peer *p; int found = 0; char *ext, *host; - char tmp[256] = ""; + char tmp[256]; int res = AST_DEVICE_INVALID; ast_copy_string(tmp, dest, sizeof(tmp)); Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.836 diff -u -r1.836 chan_sip.c --- channels/chan_sip.c 2 Sep 2005 19:24:32 -0000 1.836 +++ channels/chan_sip.c 6 Sep 2005 00:37:57 -0000 @@ -1330,7 +1330,7 @@ __sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), cur->method); else { /* Unknown packet type */ char *c; - char method[128]=""; + char method[128]; ast_copy_string(method, p->packets->data, sizeof(method)); c = ast_skip_blanks(method); /* XXX what ? */ *c = '\0'; @@ -1511,8 +1511,8 @@ /*--- realtime_update_peer: Update peer object in realtime storage ---*/ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, int expirey) { - char port[10] = ""; - char ipaddr[20] = ""; + char port[10]; + char ipaddr[20]; char regseconds[20] = "0"; if (expirey) { /* Registration */ @@ -1529,7 +1529,7 @@ /*--- register_peer_exten: Automatically add peer extension to dial plan ---*/ static void register_peer_exten(struct sip_peer *peer, int onoff) { - char multi[256]=""; + char multi[256]; char *stringp, *ext; if (!ast_strlen_zero(regcontext)) { ast_copy_string(multi, ast_strlen_zero(peer->regexten) ? peer->name : peer->regexten, sizeof(multi)); @@ -1591,7 +1591,7 @@ struct ast_variable *var; struct ast_variable *tmp; char *newpeername = (char *) peername; - char iabuf[80] = ""; + char iabuf[80]; /* First check on peer name */ if (newpeername) @@ -1840,7 +1840,7 @@ char *port; int portno; char host[MAXHOSTNAMELEN], *hostn; - char peer[256]=""; + char peer[256]; ast_copy_string(peer, opeer, sizeof(peer)); port = strchr(peer, ':'); @@ -2100,7 +2100,7 @@ /* Thought: For realtime, we should propably update storage with inuse counter... */ static int update_call_counter(struct sip_pvt *fup, int event) { - char name[256] = ""; + char name[256]; int *inuse, *call_limit; int outgoing = ast_test_flag(fup, SIP_OUTGOING); struct sip_user *u = NULL; @@ -2996,7 +2996,7 @@ { struct sip_pvt *p; char *callid; - char tmp[256] = ""; + char tmp[256]; char *tag = "", *c; callid = get_header(req, "Call-ID"); @@ -3050,7 +3050,7 @@ static int sip_register(char *value, int lineno) { struct sip_registry *reg; - char copy[256] = ""; + char copy[256]; char *username=NULL, *hostname=NULL, *secret=NULL, *authuser=NULL; char *porta=NULL; char *contact=NULL; @@ -3617,7 +3617,7 @@ /*--- copy_via_headers: Copy SIP VIA Headers from one request to another ---*/ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct sip_request *orig, char *field) { - char tmp[256]="", *oh, *end; + char tmp[256], *oh, *end; int start = 0; int copied = 0; char new[256]; @@ -3685,7 +3685,7 @@ /*--- set_destination: Set destination from SIP URI ---*/ static void set_destination(struct sip_pvt *p, char *uri) { - char *h, *maddr, hostname[256] = ""; + char *h, *maddr, hostname[256]; char iabuf[INET_ADDRSTRLEN]; int port, hn; struct hostent *hp; @@ -3710,7 +3710,8 @@ h += 5; } hn = strcspn(h, ":;>") + 1; - if (hn > sizeof(hostname)) hn = sizeof(hostname); + if (hn > sizeof(hostname)) + hn = sizeof(hostname); ast_copy_string(hostname, h, hn); h += hn - 1; @@ -3780,7 +3781,7 @@ /*--- respprep: Prepare SIP response packet ---*/ static int respprep(struct sip_request *resp, struct sip_pvt *p, char *msg, struct sip_request *req) { - char newto[256] = "", *ot; + char newto[256], *ot; memset(resp, 0, sizeof(*resp)); init_resp(resp, msg, req); @@ -3832,7 +3833,7 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch) { struct sip_request *orig = &p->initreq; - char stripped[80] =""; + char stripped[80]; char tmp[80]; char newto[256]; char *c, *n; @@ -3853,7 +3854,6 @@ build_via(p, p->via, sizeof(p->via)); } - /* Check for strict or loose router */ if (p->route && !ast_strlen_zero(p->route->hop) && strstr(p->route->hop,";lr") == NULL) is_strict = 1; @@ -4077,15 +4077,15 @@ char costr[80]; struct sockaddr_in sin; struct sockaddr_in vsin; - char v[256] = ""; - char s[256] = ""; - char o[256] = ""; - char c[256] = ""; - char t[256] = ""; - char m[256] = ""; - char m2[256] = ""; - char a[1024] = ""; - char a2[1024] = ""; + char v[256]; + char s[256]; + char o[256]; + char c[256]; + char t[256]; + char m[256]; + char m2[256]; + char a[1024]; + char a2[1024]; char iabuf[INET_ADDRSTRLEN]; int x = 0; int capability = 0 ; @@ -4367,7 +4367,7 @@ /*--- extract_uri: Check Contact: URI of SIP message ---*/ static void extract_uri(struct sip_pvt *p, struct sip_request *req) { - char stripped[256]=""; + char stripped[256]; char *c, *n; ast_copy_string(stripped, get_header(req, "Contact"), sizeof(stripped)); c = get_in_brackets(stripped); @@ -5366,7 +5366,7 @@ /*--- parse_ok_contact: Parse contact header for 200 OK on INVITE ---*/ static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req) { - char contact[250]= ""; + char contact[250]; char *c, *n, *pt; int port; struct hostent *hp; @@ -5436,7 +5436,7 @@ /*--- parse_contact: Parse contact header and save registration ---*/ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req) { - char contact[80]= ""; + char contact[80]; char data[256]; char iabuf[INET_ADDRSTRLEN]; char *expires = get_header(req, "Expires"); @@ -5770,7 +5770,7 @@ char a2_hash[256]; char resp[256]; char resp_hash[256]=""; - char tmp[256] = ""; + char tmp[256]; char *c; char *z; char *ua_hash =""; @@ -5928,7 +5928,7 @@ { int res = -3; struct sip_peer *peer; - char tmp[256] = ""; + char tmp[256]; char iabuf[INET_ADDRSTRLEN]; char *name, *c; char *t; @@ -6039,7 +6039,7 @@ /*--- get_rdnis: get referring dnis ---*/ static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq) { - char tmp[256] = "", *c, *a; + char tmp[256], *c, *a; struct sip_request *req; req = oreq; @@ -6068,7 +6068,7 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) { char tmp[256] = "", *c, *a; - char tmpf[256]= "", *fr; + char tmpf[256], *fr; struct sip_request *req; req = oreq; @@ -6305,7 +6305,7 @@ /*--- get_also_info: Call transfer support (old way, depreciated)--*/ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq) { - char tmp[256] = "", *c, *a; + char tmp[256], *c, *a; struct sip_request *req; req = oreq; @@ -6347,13 +6347,12 @@ /*--- check_via: check Via: headers ---*/ static int check_via(struct sip_pvt *p, struct sip_request *req) { - char via[256] = ""; + char via[256]; char iabuf[INET_ADDRSTRLEN]; char *c, *pt; struct hostent *hp; struct ast_hostent ahp; - memset(via, 0, sizeof(via)); ast_copy_string(via, get_header(req, "Via"), sizeof(via)); c = strchr(via, ';'); if (c) @@ -6467,7 +6466,7 @@ { struct sip_user *user; struct sip_peer *peer; - char *of, from[256] = "", *c; + char *of, from[256], *c; char *rpid,rpid_num[50]; char iabuf[INET_ADDRSTRLEN]; int res = 0; @@ -6791,7 +6790,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) { #define FORMAT "%-25.25s %-15.15s %-15.15s \n" #define FORMAT2 "%-25.25s %-15.15s %-15.15s \n" - char ilimits[40] = ""; + char ilimits[40]; char iused[40]; int showall = 0; @@ -6971,7 +6970,7 @@ #define FORMAT2 "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-15.15s %-8s %-10s\n" #define FORMAT "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-15.15s %-8d %-10s\n" - char name[256] = ""; + char name[256]; char iabuf[INET_ADDRSTRLEN]; int total_peers = 0; int peers_online = 0; @@ -8081,7 +8080,7 @@ /* Doesn't read the duration of the DTMF signal */ static void handle_request_info(struct sip_pvt *p, struct sip_request *req) { - char buf[1024] = ""; + char buf[1024]; unsigned int event; char resp = 0; struct ast_frame f; @@ -8392,7 +8391,7 @@ static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len) { - char tmp[512] = ""; + char tmp[512]; char *c; /* table of recognised keywords, and places where they should be copied */ @@ -8466,7 +8465,7 @@ char a2_hash[256]; char resp[256]; char resp_hash[256]; - char uri[256] = ""; + char uri[256]; char cnonce[80]; char iabuf[INET_ADDRSTRLEN]; char *username; @@ -8832,7 +8831,7 @@ /*--- parse_moved_contact: Parse 302 Moved temporalily response */ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req) { - char tmp[256] = ""; + char tmp[256]; char *s, *e; ast_copy_string(tmp, get_header(req, "Contact"), sizeof(tmp)); s = get_in_brackets(tmp); @@ -10364,7 +10363,7 @@ } memcpy(&p->recv, &sin, sizeof(p->recv)); if (recordhistory) { - char tmp[80] = ""; + char tmp[80]; /* This is a response, note what it was for */ snprintf(tmp, sizeof(tmp), "%s / %s", req.data, get_header(&req, "CSeq")); append_history(p, "Rx", tmp); @@ -10668,7 +10667,7 @@ static int sip_devicestate(void *data) { char *ext, *host; - char tmp[256] = ""; + char tmp[256]; char *dest = data; struct hostent *hp; @@ -10732,7 +10731,7 @@ struct sip_pvt *p; struct ast_channel *tmpc = NULL; char *ext, *host; - char tmp[256] = ""; + char tmp[256]; char *dest = data; oldformat = format; @@ -10913,7 +10912,7 @@ /*--- add_realm_authentication: Add realm authentication in list ---*/ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno) { - char authcopy[256] = ""; + char authcopy[256]; char *username=NULL, *realm=NULL, *secret=NULL, *md5secret=NULL; char *stringp; struct sip_auth *auth; Index: pbx/pbx_dundi.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_dundi.c,v retrieving revision 1.40 diff -u -r1.40 pbx_dundi.c --- pbx/pbx_dundi.c 2 Sep 2005 19:15:03 -0000 1.40 +++ pbx/pbx_dundi.c 6 Sep 2005 00:38:02 -0000 @@ -540,7 +540,7 @@ dr[anscnt].techint = map->tech; dr[anscnt].weight = map->weight; dr[anscnt].expiration = dundi_cache_time; - strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech)); + ast_copy_string(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech)); dr[anscnt].eid = *us_eid; dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid); if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) { @@ -564,7 +564,7 @@ } else { /* No answers... Find the fewest number of digits from the number for which we have no answer. */ - char tmp[AST_MAX_EXTENSION]=""; + char tmp[AST_MAX_EXTENSION]; for (x=0;x strlen(hmd->exten)) { - strncpy(hmd->exten, tmp, sizeof(hmd->exten) - 1); + ast_copy_string(hmd->exten, tmp, sizeof(hmd->exten)); } break; } @@ -698,13 +698,13 @@ if (!dundi_eid_cmp(&st->trans->us_eid, &st->reqeid)) { /* Ooh, it's us! */ ast_log(LOG_DEBUG, "Neat, someone look for us!\n"); - strncpy(dei.orgunit, dept, sizeof(dei.orgunit)); - strncpy(dei.org, org, sizeof(dei.org)); - strncpy(dei.locality, locality, sizeof(dei.locality)); - strncpy(dei.stateprov, stateprov, sizeof(dei.stateprov)); - strncpy(dei.country, country, sizeof(dei.country)); - strncpy(dei.email, email, sizeof(dei.email)); - strncpy(dei.phone, phone, sizeof(dei.phone)); + ast_copy_string(dei.orgunit, dept, sizeof(dei.orgunit)); + ast_copy_string(dei.org, org, sizeof(dei.org)); + ast_copy_string(dei.locality, locality, sizeof(dei.locality)); + ast_copy_string(dei.stateprov, stateprov, sizeof(dei.stateprov)); + ast_copy_string(dei.country, country, sizeof(dei.country)); + ast_copy_string(dei.email, email, sizeof(dei.email)); + ast_copy_string(dei.phone, phone, sizeof(dei.phone)); res = 1; } else { /* If we do not have a canonical result, keep looking */ @@ -760,7 +760,7 @@ st = malloc(totallen); if (st) { memset(st, 0, totallen); - strncpy(st->called_context, ies->called_context, sizeof(st->called_context) - 1); + ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context)); memcpy(&st->reqeid, ies->reqeid, sizeof(st->reqeid)); st->trans = trans; st->ttl = ies->ttl - 1; @@ -802,7 +802,7 @@ char key2[256]; char eidpeer_str[20]; char eidroot_str[20]; - char data[80]=""; + char data[80]; time_t timeout; if (expiration < 0) @@ -835,7 +835,7 @@ int x; char key1[256]; char key2[256]; - char data[1024]=""; + char data[1024]; char eidpeer_str[20]; char eidroot_str[20]; time_t timeout; @@ -901,8 +901,8 @@ dr.hmd = &hmd; dr.pfds[0] = dr.pfds[1] = -1; trans->parent = &dr; - strncpy(dr.dcontext, ies->called_context ? ies->called_context : "e164", sizeof(dr.dcontext)); - strncpy(dr.number, ies->called_number, sizeof(dr.number) - 1); + ast_copy_string(dr.dcontext, ies->called_context ? ies->called_context : "e164", sizeof(dr.dcontext)); + ast_copy_string(dr.number, ies->called_number, sizeof(dr.number)); for (x=0;xanscount;x++) { if (trans->parent->respcount < trans->parent->maxcount) { @@ -925,9 +925,9 @@ dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, sizeof(trans->parent->dr[trans->parent->respcount].eid_str), &ies->answers[x]->eid); - strncpy(trans->parent->dr[trans->parent->respcount].dest, (char *)ies->answers[x]->data, + ast_copy_string(trans->parent->dr[trans->parent->respcount].dest, (char *)ies->answers[x]->data, sizeof(trans->parent->dr[trans->parent->respcount].dest)); - strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies->answers[x]->protocol), + ast_copy_string(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies->answers[x]->protocol), sizeof(trans->parent->dr[trans->parent->respcount].tech)); trans->parent->respcount++; ast_clear_flag_nonstd(trans->parent->hmd, DUNDI_HINT_DONT_ASK); @@ -974,8 +974,8 @@ st = malloc(totallen); if (st) { memset(st, 0, totallen); - strncpy(st->called_context, ies->called_context, sizeof(st->called_context) - 1); - strncpy(st->called_number, ies->called_number, sizeof(st->called_number) - 1); + ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context)); + ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number)); st->trans = trans; st->ttl = ies->ttl - 1; st->nocache = ies->cbypass; @@ -1066,8 +1066,8 @@ st = malloc(totallen); if (st) { memset(st, 0, totallen); - strncpy(st->called_context, ies->called_context, sizeof(st->called_context) - 1); - strncpy(st->called_number, ies->called_number, sizeof(st->called_number) - 1); + ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context)); + ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number)); st->trans = trans; st->ttl = ies->ttl - 1; st->nocache = ies->cbypass; @@ -1120,7 +1120,7 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *key, char *eid_str_full, int *lowexpiration) { - char data[1024]=""; + char data[1024]; char *ptr, *term, *src; int tech; struct ast_flags flags; @@ -1166,9 +1166,9 @@ dundi_str_short_to_eid(&req->dr[req->respcount].eid, src); dundi_eid_to_str(req->dr[req->respcount].eid_str, sizeof(req->dr[req->respcount].eid_str), &req->dr[req->respcount].eid); - strncpy(req->dr[req->respcount].dest, ptr, + ast_copy_string(req->dr[req->respcount].dest, ptr, sizeof(req->dr[req->respcount].dest)); - strncpy(req->dr[req->respcount].tech, tech2str(tech), + ast_copy_string(req->dr[req->respcount].tech, tech2str(tech), sizeof(req->dr[req->respcount].tech)); req->respcount++; ast_clear_flag_nonstd(req->hmd, DUNDI_HINT_DONT_ASK); @@ -1230,7 +1230,7 @@ if (res2) { if (strlen(tmp) > strlen(req->hmd->exten)) { /* Update meta data if appropriate */ - strncpy(req->hmd->exten, tmp, sizeof(req->hmd->exten) - 1); + ast_copy_string(req->hmd->exten, tmp, sizeof(req->hmd->exten)); } } } @@ -1660,9 +1660,9 @@ dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, sizeof(trans->parent->dr[trans->parent->respcount].eid_str), &ies.answers[x]->eid); - strncpy(trans->parent->dr[trans->parent->respcount].dest, (char *)ies.answers[x]->data, + ast_copy_string(trans->parent->dr[trans->parent->respcount].dest, (char *)ies.answers[x]->data, sizeof(trans->parent->dr[trans->parent->respcount].dest)); - strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies.answers[x]->protocol), + ast_copy_string(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies.answers[x]->protocol), sizeof(trans->parent->dr[trans->parent->respcount].tech)); trans->parent->respcount++; ast_clear_flag_nonstd(trans->parent->hmd, DUNDI_HINT_DONT_ASK); @@ -1684,8 +1684,8 @@ ast_set_flag_nonstd(trans->parent->hmd, DUNDI_HINT_TTL_EXPIRED); if (ast_test_flag_nonstd(ies.hint, htons(DUNDI_HINT_DONT_ASK))) { if (strlen((char *)ies.hint->data) > strlen(trans->parent->hmd->exten)) { - strncpy(trans->parent->hmd->exten, (char *)ies.hint->data, - sizeof(trans->parent->hmd->exten) - 1); + ast_copy_string(trans->parent->hmd->exten, (char *)ies.hint->data, + sizeof(trans->parent->hmd->exten)); } } else { ast_clear_flag_nonstd(trans->parent->hmd, DUNDI_HINT_DONT_ASK); @@ -1725,21 +1725,21 @@ if (!trans->parent->respcount) { trans->parent->respcount++; if (ies.q_dept) - strncpy(trans->parent->dei->orgunit, ies.q_dept, sizeof(trans->parent->dei->orgunit) - 1); + ast_copy_string(trans->parent->dei->orgunit, ies.q_dept, sizeof(trans->parent->dei->orgunit)); if (ies.q_org) - strncpy(trans->parent->dei->org, ies.q_org, sizeof(trans->parent->dei->org) - 1); + ast_copy_string(trans->parent->dei->org, ies.q_org, sizeof(trans->parent->dei->org)); if (ies.q_locality) - strncpy(trans->parent->dei->locality, ies.q_locality, sizeof(trans->parent->dei->locality) - 1); + ast_copy_string(trans->parent->dei->locality, ies.q_locality, sizeof(trans->parent->dei->locality)); if (ies.q_stateprov) - strncpy(trans->parent->dei->stateprov, ies.q_stateprov, sizeof(trans->parent->dei->stateprov) - 1); + ast_copy_string(trans->parent->dei->stateprov, ies.q_stateprov, sizeof(trans->parent->dei->stateprov)); if (ies.q_country) - strncpy(trans->parent->dei->country, ies.q_country, sizeof(trans->parent->dei->country) - 1); + ast_copy_string(trans->parent->dei->country, ies.q_country, sizeof(trans->parent->dei->country)); if (ies.q_email) - strncpy(trans->parent->dei->email, ies.q_email, sizeof(trans->parent->dei->email) - 1); + ast_copy_string(trans->parent->dei->email, ies.q_email, sizeof(trans->parent->dei->email)); if (ies.q_phone) - strncpy(trans->parent->dei->phone, ies.q_phone, sizeof(trans->parent->dei->phone) - 1); + ast_copy_string(trans->parent->dei->phone, ies.q_phone, sizeof(trans->parent->dei->phone)); if (ies.q_ipaddr) - strncpy(trans->parent->dei->ipaddr, ies.q_ipaddr, sizeof(trans->parent->dei->ipaddr) - 1); + ast_copy_string(trans->parent->dei->ipaddr, ies.q_ipaddr, sizeof(trans->parent->dei->ipaddr)); if (!dundi_eid_cmp(&trans->them_eid, &trans->parent->query_eid)) { /* If it's them, update our address */ ast_inet_ntoa(trans->parent->dei->ipaddr, sizeof(trans->parent->dei->ipaddr), @@ -2050,7 +2050,7 @@ } if (current) { /* Current key is still valid, just setup rotatation properly */ - strncpy(cursecret, current, sizeof(cursecret) - 1); + ast_copy_string(cursecret, current, sizeof(cursecret)); rotatetime = expired; } else { /* Current key is out of date, rotate or eliminate all together */ @@ -2070,7 +2070,7 @@ #endif if ((now - rotatetime) >= 0) { /* Time to rotate keys */ - strncpy(oldsecret, cursecret, sizeof(oldsecret) - 1); + ast_copy_string(oldsecret, cursecret, sizeof(oldsecret)); build_secret(cursecret, sizeof(cursecret)); save_secret(cursecret, oldsecret); } @@ -2102,8 +2102,8 @@ { struct dundi_precache_queue *qe; time_t now; - char context[256]=""; - char number[256]=""; + char context[256]; + char number[256]; int run; for (;;) { time(&now); @@ -2118,8 +2118,8 @@ } else if (pcq->expiration < now) { /* Process this entry */ pcq->expiration = 0; - strncpy(context, pcq->context, sizeof(context) - 1); - strncpy(number, pcq->number, sizeof(number) - 1); + ast_copy_string(context, pcq->context, sizeof(context)); + ast_copy_string(number, pcq->number, sizeof(number)); run = 1; } } @@ -2274,7 +2274,7 @@ static int dundi_do_lookup(int fd, int argc, char *argv[]) { int res; - char tmp[256] = ""; + char tmp[256]; char fs[80] = ""; char *context; int x; @@ -2289,7 +2289,7 @@ else return RESULT_SHOWUSAGE; } - strncpy(tmp, argv[2], sizeof(tmp) - 1); + ast_copy_string(tmp, argv[2], sizeof(tmp)); context = strchr(tmp, '@'); if (context) { *context = '\0'; @@ -2315,12 +2315,12 @@ static int dundi_do_precache(int fd, int argc, char *argv[]) { int res; - char tmp[256] = ""; + char tmp[256]; char *context; struct timeval start; if ((argc < 3) || (argc > 3)) return RESULT_SHOWUSAGE; - strncpy(tmp, argv[2], sizeof(tmp) - 1); + ast_copy_string(tmp, argv[2], sizeof(tmp)); context = strchr(tmp, '@'); if (context) { *context = '\0'; @@ -2340,7 +2340,7 @@ static int dundi_do_query(int fd, int argc, char *argv[]) { int res; - char tmp[256] = ""; + char tmp[256]; char *context; dundi_eid eid; struct dundi_entity_info dei; @@ -2350,7 +2350,7 @@ ast_cli(fd, "'%s' is not a valid EID!\n", argv[2]); return RESULT_SHOWUSAGE; } - strncpy(tmp, argv[2], sizeof(tmp) - 1); + ast_copy_string(tmp, argv[2], sizeof(tmp)); context = strchr(tmp, '@'); if (context) { *context = '\0'; @@ -2476,15 +2476,15 @@ ast_mutex_lock(&peerlock); ast_cli(fd, FORMAT2, "EID", "Host", "Model", "AvgTime", "Status"); for (peer = peers;peer;peer = peer->next) { - char status[20] = ""; - int print_line = -1; - char srch[2000] = ""; + char status[20]; + int print_line = -1; + char srch[2000]; total_peers++; if (registeredonly && !peer->addr.sin_addr.s_addr) continue; if (peer->maxms) { if (peer->lastms < 0) { - strncpy(status, "UNREACHABLE", sizeof(status) - 1); + strcpy(status, "UNREACHABLE"); offline_peers++; } else if (peer->lastms > peer->maxms) { @@ -2496,11 +2496,11 @@ online_peers++; } else { - strncpy(status, "UNKNOWN", sizeof(status) - 1); + strcpy(status, "UNKOWN"); offline_peers++; } } else { - strncpy(status, "Unmonitored", sizeof(status) - 1); + strcpy(status, "Unmonitored"); unmonitored_peers++; } if (peer->avgms) @@ -3548,8 +3548,8 @@ dr.expiration = *expiration; dr.cbypass = cbypass; dr.crc32 = avoid_crc32(avoid); - strncpy(dr.dcontext, dcontext ? dcontext : "e164", sizeof(dr.dcontext) - 1); - strncpy(dr.number, number, sizeof(dr.number) - 1); + ast_copy_string(dr.dcontext, dcontext ? dcontext : "e164", sizeof(dr.dcontext)); + ast_copy_string(dr.number, number, sizeof(dr.number)); if (rooteid) dr.root_eid = *rooteid; res = register_request(&dr, &pending); @@ -3741,8 +3741,8 @@ memset(&dr, 0, sizeof(dr)); memset(&hmd, 0, sizeof(hmd)); dr.dr = dr2; - strncpy(dr.number, number, sizeof(dr.number) - 1); - strncpy(dr.dcontext, context ? context : "e164", sizeof(dr.dcontext) - 1); + ast_copy_string(dr.number, number, sizeof(dr.number)); + ast_copy_string(dr.dcontext, context ? context : "e164", sizeof(dr.dcontext)); dr.maxcount = MAX_RESULTS; dr.expiration = dundi_cache_time; dr.hmd = &hmd; @@ -3800,7 +3800,7 @@ dr.hmd = hmd; dr.dei = dei; dr.pfds[0] = dr.pfds[1] = -1; - strncpy(dr.dcontext, dcontext ? dcontext : "e164", sizeof(dr.dcontext) - 1); + ast_copy_string(dr.dcontext, dcontext ? dcontext : "e164", sizeof(dr.dcontext)); memcpy(&dr.query_eid, eid, sizeof(dr.query_eid)); if (rooteid) dr.root_eid = *rooteid; @@ -4051,13 +4051,13 @@ } /* Russell was here, arrrr! */ if ((x == 1) && ast_strlen_zero(fields[0])) { /* Placeholder mapping */ - strncpy(map->dcontext, name, sizeof(map->dcontext) - 1); + ast_copy_string(map->dcontext, name, sizeof(map->dcontext)); map->dead = 0; } else if (x >= 4) { - strncpy(map->dcontext, name, sizeof(map->dcontext) - 1); - strncpy(map->lcontext, fields[0], sizeof(map->lcontext) - 1); + ast_copy_string(map->dcontext, name, sizeof(map->dcontext)); + ast_copy_string(map->lcontext, fields[0], sizeof(map->lcontext)); if ((sscanf(fields[1], "%d", &map->weight) == 1) && (map->weight >= 0) && (map->weight < 60000)) { - strncpy(map->dest, fields[3], sizeof(map->dest) - 1); + ast_copy_string(map->dest, fields[3], sizeof(map->dest)); if ((map->tech = str2tech(fields[2]))) { map->dead = 0; } @@ -4216,9 +4216,9 @@ peer->registerid = -1; while(v) { if (!strcasecmp(v->name, "inkey")) { - strncpy(peer->inkey, v->value, sizeof(peer->inkey) - 1); + ast_copy_string(peer->inkey, v->value, sizeof(peer->inkey)); } else if (!strcasecmp(v->name, "outkey")) { - strncpy(peer->outkey, v->value, sizeof(peer->outkey) - 1); + ast_copy_string(peer->outkey, v->value, sizeof(peer->outkey)); } else if (!strcasecmp(v->name, "host")) { if (!strcasecmp(v->value, "dynamic")) { peer->dynamic = 1; @@ -4450,7 +4450,7 @@ char *cat; int format; int x; - char hn[MAXHOSTNAMELEN]=""; + char hn[MAXHOSTNAMELEN] = ""; struct ast_hostent he; struct hostent *hp; struct sockaddr_in sin2; @@ -4480,7 +4480,7 @@ ast_mutex_lock(&peerlock); reset_global_eid(); global_storehistory = 0; - strncpy(secretpath, "dundi", sizeof(secretpath) - 1); + ast_copy_string(secretpath, "dundi", sizeof(secretpath)); v = ast_variable_browse(cfg, "general"); while(v) { if (!strcasecmp(v->name, "port")){ @@ -4544,19 +4544,19 @@ ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', or 'none'\n", v->lineno); #endif } else if (!strcasecmp(v->name, "department")) { - strncpy(dept, v->value, sizeof(dept) - 1); + ast_copy_string(dept, v->value, sizeof(dept)); } else if (!strcasecmp(v->name, "organization")) { - strncpy(org, v->value, sizeof(org) - 1); + ast_copy_string(org, v->value, sizeof(org)); } else if (!strcasecmp(v->name, "locality")) { - strncpy(locality, v->value, sizeof(locality) - 1); + ast_copy_string(locality, v->value, sizeof(locality)); } else if (!strcasecmp(v->name, "stateprov")) { - strncpy(stateprov, v->value, sizeof(stateprov) - 1); + ast_copy_string(stateprov, v->value, sizeof(stateprov)); } else if (!strcasecmp(v->name, "country")) { - strncpy(country, v->value, sizeof(country) - 1); + ast_copy_string(country, v->value, sizeof(country)); } else if (!strcasecmp(v->name, "email")) { - strncpy(email, v->value, sizeof(email) - 1); + ast_copy_string(email, v->value, sizeof(email)); } else if (!strcasecmp(v->name, "phone")) { - strncpy(phone, v->value, sizeof(phone) - 1); + ast_copy_string(phone, v->value, sizeof(phone)); } else if (!strcasecmp(v->name, "storehistory")) { global_storehistory = ast_true(v->value); } else if (!strcasecmp(v->name, "cachetime")) { Index: res/res_features.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_features.c,v retrieving revision 1.68 diff -u -r1.68 res_features.c --- res/res_features.c 23 Aug 2005 15:33:27 -0000 1.68 +++ res/res_features.c 6 Sep 2005 00:38:03 -0000 @@ -247,11 +247,11 @@ { int res; int justify[5] = {ADSI_JUST_CENT, ADSI_JUST_CENT, ADSI_JUST_CENT, ADSI_JUST_CENT}; - char tmp[256] = ""; - unsigned char *message[5] = {NULL, NULL, NULL, NULL, NULL}; + char tmp[256]; + char *message[5] = {NULL, NULL, NULL, NULL, NULL}; snprintf(tmp, sizeof(tmp), "Parked on %d", parkingnum); - message[0] = (unsigned char *)tmp; + message[0] = tmp; res = adsi_load_session(chan, NULL, 0, 1); if (res == -1) { return res;