diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 15:23:19 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 15:23:19 +0000 |
commit | dac373f5395aca9a9f3f75b089e415ec6f0a51f4 (patch) | |
tree | 5c5be0ea22d3b81ee644e5f620052a4f25f14e02 /channels | |
parent | b9f6c27beb072516a1bec8b7261b05ac902c2093 (diff) |
Corydon posted this janitor project to the bug tracker and mvanbaak provided
a patch for it. It replaces a bunch of simple calls to snprintf with ast_copy_string
(closes issue #10843)
Reported by: Corydon76
Patches:
2007092900_10843.diff uploaded by mvanbaak (license 7)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@84173 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 4 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 16 | ||||
-rw-r--r-- | channels/chan_misdn.c | 2 | ||||
-rw-r--r-- | channels/chan_sip.c | 4 | ||||
-rw-r--r-- | channels/chan_skinny.c | 6 | ||||
-rw-r--r-- | channels/iax2-parser.c | 2 |
6 files changed, 17 insertions, 17 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 882340586..516ac32a8 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -5969,9 +5969,9 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c else if (reg->messages > 1) snprintf(msgstatus, sizeof(msgstatus), " with %d new messages waiting\n", reg->messages); else if (reg->messages > 0) - snprintf(msgstatus, sizeof(msgstatus), " with 1 new message waiting\n"); + ast_copy_string(msgstatus, " with 1 new message waiting\n", sizeof(msgstatus)); else - snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n"); + ast_copy_string(msgstatus, " with no messages waiting\n", sizeof(msgstatus)); snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port)); ast_verb(3, "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(sin->sin_addr), ourip, msgstatus); manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(sin->sin_addr)); diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 3ffbcf83a..7693397c7 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -882,7 +882,7 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout) ast_verb(3, "MGCP distinctive callwait %s\n", tone); } } else { - snprintf(tone, sizeof(tone), "L/wt"); + ast_copy_string(tone, "L/wt", sizeof(tone)); if (mgcpdebug) { ast_verb(3, "MGCP normal callwait %s\n", tone); } @@ -896,7 +896,7 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout) ast_verb(3, "MGCP distinctive ring %s\n", tone); } } else { - snprintf(tone, sizeof(tone), "L/rg"); + ast_copy_string(tone, "L/rg", sizeof(tone)); if (mgcpdebug) { ast_verb(3, "MGCP default ring\n"); } @@ -1932,7 +1932,7 @@ static int add_line(struct mgcp_request *req, char *line) } if (!req->lines) { /* Add extra empty return */ - snprintf(req->data + req->len, sizeof(req->data) - req->len, "\r\n"); + ast_copy_string(req->data + req->len, "\r\n", sizeof(req->data) - req->len); req->len += strlen(req->data + req->len); } req->line[req->lines] = req->data + req->len; @@ -2065,11 +2065,11 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc if (mgcpdebug) { ast_verbose("We're at %s port %d\n", ast_inet_ntoa(p->parent->ourip), ntohs(sin.sin_port)); } - snprintf(v, sizeof(v), "v=0\r\n"); + ast_copy_string(v, "v=0\r\n", sizeof(v)); snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", (int)getpid(), (int)getpid(), ast_inet_ntoa(dest.sin_addr)); - snprintf(s, sizeof(s), "s=session\r\n"); + ast_copy_string(s, "s=session\r\n", sizeof(s)); snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr)); - snprintf(t, sizeof(t), "t=0 0\r\n"); + ast_copy_string(t, "t=0 0\r\n", sizeof(t)); snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port)); for (x = 1; x <= AST_FORMAT_MAX_AUDIO; x <<= 1) { if (p->capability & x) { @@ -2136,7 +2136,7 @@ static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp ast_rtp_get_peer(rtp, &sub->tmpdest); return 0; } - snprintf(local, sizeof(local), "p:20"); + ast_copy_string(local, "p:20", sizeof(local)); for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) { if (p->capability & x) { snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0)); @@ -2166,7 +2166,7 @@ static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp int x; struct mgcp_endpoint *p = sub->parent; - snprintf(local, sizeof(local), "p:20"); + ast_copy_string(local, "p:20", sizeof(local)); for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) { if (p->capability & x) { snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0)); diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index d95441a0d..f93963ab1 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -1701,7 +1701,7 @@ static int update_pipeline_config(struct misdn_bchannel *bc) misdn_cfg_get(bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(ec)); if (ec == 1) - snprintf(bc->pipeline, sizeof(bc->pipeline), "mg2ec"); + ast_copy_string(bc->pipeline, "mg2ec", sizeof(bc->pipeline)); else if (ec > 1) snprintf(bc->pipeline, sizeof(bc->pipeline), "mg2ec(deftaps=%d)", ec); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 02606fd68..c671b62bd 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2586,7 +2586,7 @@ static void add_blank(struct sip_request *req) { if (!req->lines) { /* Add extra empty return. add_header() reserves 4 bytes so cannot be truncated */ - snprintf(req->data + req->len, sizeof(req->data) - req->len, "\r\n"); + ast_copy_string(req->data + req->len, "\r\n", sizeof(req->data) - req->len); req->len += strlen(req->data + req->len); } } @@ -6175,7 +6175,7 @@ static int add_line(struct sip_request *req, const char *line) } if (!req->lines) { /* Add extra empty return */ - snprintf(req->data + req->len, sizeof(req->data) - req->len, "\r\n"); + ast_copy_string(req->data + req->len, "\r\n", sizeof(req->data) - req->len); req->len += strlen(req->data + req->len); } if (req->len >= sizeof(req->data) - 4) { diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 69fa9536f..b1a83abbe 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -4221,8 +4221,8 @@ static int handle_speed_dial_stat_req_message(struct skinny_req *req, struct ski return -1; req->data.speeddialreq.speedDialNumber = htolel(instance); - snprintf(req->data.speeddial.speedDialDirNumber, sizeof(req->data.speeddial.speedDialDirNumber), sd->exten); - snprintf(req->data.speeddial.speedDialDisplayName, sizeof(req->data.speeddial.speedDialDisplayName), sd->label); + ast_copy_string(req->data.speeddial.speedDialDirNumber, sd->exten, sizeof(req->data.speeddial.speedDialDirNumber)); + ast_copy_string(req->data.speeddial.speedDialDisplayName, sd->label, sizeof(req->data.speeddial.speedDialDisplayName)); transmit_response(s, req); return 1; @@ -4442,7 +4442,7 @@ static int handle_version_req_message(struct skinny_req *req, struct skinnysessi if (!(req = req_alloc(sizeof(struct version_res_message), VERSION_RES_MESSAGE))) return -1; - snprintf(req->data.version.version, sizeof(req->data.version.version), d->version_id); + ast_copy_string(req->data.version.version, d->version_id, sizeof(req->data.version.version)); transmit_response(s, req); return 1; } diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c index b6c4befcc..0422ab67f 100644 --- a/channels/iax2-parser.c +++ b/channels/iax2-parser.c @@ -82,7 +82,7 @@ static void dump_addr(char *output, int maxlen, void *value, int len) memcpy(&sin, value, len); snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); } else { - snprintf(output, maxlen, "Invalid Address"); + ast_copy_string(output, "Invalid Address", maxlen); } } |