dect
/
asterisk
Archived
13
0
Fork 0

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
This commit is contained in:
russell 2007-10-01 15:23:19 +00:00
parent b9f6c27beb
commit dac373f539
14 changed files with 189 additions and 189 deletions

View File

@ -1477,7 +1477,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
}
conf->recordingformat = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT");
if (!conf->recordingformat) {
snprintf(recordingtmp, sizeof(recordingtmp), "wav");
ast_copy_string(recordingtmp, "wav", sizeof(recordingtmp));
conf->recordingformat = ast_strdupa(recordingtmp);
}
ast_verb(4, "Starting recording of MeetMe Conference %s into file %s.%s.\n",

View File

@ -934,7 +934,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
char tmpcmd[PATH_MAX];
int tmpfd;
snprintf(newtmp, sizeof(newtmp), "/tmp/XXXXXX");
ast_copy_string(newtmp, "/tmp/XXXXXX", sizeof(newtmp));
ast_debug(3, "newtmp: %s\n", newtmp);
tmpfd = mkstemp(newtmp);
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -1880,7 +1880,7 @@ static char *cli_prompt(EditLine *el)
} else if (remotehostname)
snprintf(prompt, sizeof(prompt), ASTERISK_PROMPT2, remotehostname);
else
snprintf(prompt, sizeof(prompt), ASTERISK_PROMPT);
ast_copy_string(prompt, ASTERISK_PROMPT, sizeof(prompt));
return(prompt);
}
@ -2206,7 +2206,7 @@ static void ast_remotecontrol(char * data)
snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
fdprint(ast_consock, tmp);
if (ast_opt_mute) {
snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
ast_copy_string(tmp, "log and verbose output currently muted ('logger unmute' to unmute)", sizeof(tmp));
fdprint(ast_consock, tmp);
}
ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);

View File

@ -555,7 +555,7 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format)
}
}
if (start == end)
snprintf(start, size, "nothing)");
ast_copy_string(start, "nothing)", size);
else if (size > 1)
*(end -1) = ')';
return buf;

View File

@ -2113,7 +2113,7 @@ char *ast_rtp_lookup_mime_multiple(char *buf, size_t size, const int capability,
}
if (start == end)
snprintf(start, size, "nothing)");
ast_copy_string(start, "nothing)", size);
else if (size > 1)
*(end -1) = ')';

File diff suppressed because it is too large Load Diff

View File

@ -229,7 +229,7 @@ static void dump_int(char *output, int maxlen, void *value, int len)
if (len == (int)sizeof(unsigned int))
snprintf(output, maxlen, "%lu", (unsigned long)ntohl(*((unsigned int *)value)));
else
snprintf(output, maxlen, "Invalid INT");
ast_copy_string(output, "Invalid INT", maxlen);
}
static void dump_short(char *output, int maxlen, void *value, int len)
@ -237,7 +237,7 @@ static void dump_short(char *output, int maxlen, void *value, int len)
if (len == (int)sizeof(unsigned short))
snprintf(output, maxlen, "%d", ntohs(*((unsigned short *)value)));
else
snprintf(output, maxlen, "Invalid SHORT");
ast_copy_string(output, "Invalid SHORT", maxlen);
}
static void dump_byte(char *output, int maxlen, void *value, int len)
@ -245,7 +245,7 @@ static void dump_byte(char *output, int maxlen, void *value, int len)
if (len == (int)sizeof(unsigned char))
snprintf(output, maxlen, "%d", *((unsigned char *)value));
else
snprintf(output, maxlen, "Invalid BYTE");
ast_copy_string(output, "Invalid BYTE", maxlen);
}
static char *proto2str(int proto, char *buf, int bufsiz)

View File

@ -496,7 +496,7 @@ static int store_odbc(const char *database, const char *table, va_list ap)
}
newval = va_arg(aq, const char *);
snprintf(keys, sizeof(keys), "%s", newparam);
snprintf(vals, sizeof(vals), "?");
ast_copy_string(vals, "?", sizeof(vals));
while ((newparam = va_arg(aq, const char *))) {
snprintf(keys + strlen(keys), sizeof(keys) - strlen(keys), ", %s", newparam);
snprintf(vals + strlen(vals), sizeof(vals) - strlen(vals), ", ?");