diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-03-18 15:58:50 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-03-18 15:58:50 +0000 |
commit | 48d2267d2d05bf4acaa2ae4e00e3d9b600cce235 (patch) | |
tree | b91e3d85242f15336883bd197abbe86cd66fdfc8 /apps | |
parent | 99e420ecd8ad845f253266482101298583994c00 (diff) |
Merged revisions 109447 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r109447 | twilson | 2008-03-18 10:43:34 -0500 (Tue, 18 Mar 2008) | 3 lines
Go through and fix a bunch of places where character strings were being interpreted as format strings. Most of these changes are solely to make compiling with -Wsecurity and -Wformat=2 happy, and were not
actual problems, per se. I also added format attributes to any printf wrapper functions I found that didn't have them. -Wsecurity and -Wmissing-format-attribute added to --enable-dev-mode.
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@109459 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_festival.c | 24 | ||||
-rw-r--r-- | apps/app_meetme.c | 8 | ||||
-rw-r--r-- | apps/app_minivm.c | 28 | ||||
-rw-r--r-- | apps/app_queue.c | 4 | ||||
-rw-r--r-- | apps/app_voicemail.c | 24 |
5 files changed, 46 insertions, 42 deletions
diff --git a/apps/app_festival.c b/apps/app_festival.c index 926638e57..e788291ed 100644 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -327,11 +327,21 @@ static int festival_exec(struct ast_channel *chan, void *vdata) if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) { cachedir = "/tmp/"; } + + data = ast_strdupa(vdata); + AST_STANDARD_APP_ARGS(args, data); + if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) { - festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n"; + const char *startcmd = "(tts_textasterisk \""; + const char *endcmd = "\" 'file)(quit)\n"; + + strln = strlen(startcmd) + strlen(args.text) + strlen(endcmd) + 1; + newfestivalcommand = alloca(strln); + snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd); + festivalcommand = newfestivalcommand; } else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */ int i, j; - newfestivalcommand = alloca(strlen(festivalcommand) + 1); + newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1); for (i = 0, j = 0; i < strlen(festivalcommand); i++) { if (festivalcommand[i] == '\\' && festivalcommand[i + 1] == 'n') { @@ -340,6 +350,10 @@ static int festival_exec(struct ast_channel *chan, void *vdata) } else if (festivalcommand[i] == '\\') { newfestivalcommand[j++] = festivalcommand[i + 1]; i++; + } else if (festivalcommand[i] == '%' && festivalcommand[i + 1] == 's') { + sprintf(&newfestivalcommand[j], "%s", args.text); /* we know it is big enough */ + j += strlen(args.text); + i++; } else newfestivalcommand[j++] = festivalcommand[i]; } @@ -347,9 +361,6 @@ static int festival_exec(struct ast_channel *chan, void *vdata) festivalcommand = newfestivalcommand; } - data = ast_strdupa(vdata); - AST_STANDARD_APP_ARGS(args, data); - if (args.interrupt && !strcasecmp(args.interrupt, "any")) args.interrupt = AST_DIGIT_ANY; @@ -440,7 +451,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata) } else { ast_debug(1, "Passing text to festival...\n"); fs = fdopen(dup(fd), "wb"); - fprintf(fs, festivalcommand, args.text); + + fprintf(fs, "%s", festivalcommand); fflush(fs); fclose(fs); } diff --git a/apps/app_meetme.c b/apps/app_meetme.c index 368cc4539..a6967a34c 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -955,9 +955,9 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a int hr, min, sec; int i = 0, total = 0; time_t now; - char *header_format = "%-14s %-14s %-10s %-8s %-8s %-6s\n"; - char *data_format = "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n"; char cmdline[1024] = ""; +#define MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n" +#define MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n" switch (cmd) { case CLI_INIT: @@ -989,7 +989,7 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a return CLI_SUCCESS; } if (!concise) - ast_cli(a->fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked"); + ast_cli(a->fd, MC_HEADER_FORMAT, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked"); AST_LIST_TRAVERSE(&confs, cnf, list) { if (cnf->markedusers == 0) strcpy(cmdline, "N/A "); @@ -999,7 +999,7 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a min = ((now - cnf->start) % 3600) / 60; sec = (now - cnf->start) % 60; if (!concise) - ast_cli(a->fd, data_format, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No"); + ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No"); else { ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n", cnf->confno, diff --git a/apps/app_minivm.c b/apps/app_minivm.c index ae76f9e89..2b70d87e4 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -1560,10 +1560,10 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav duration < global_vmminmessage ? "IGNORED" : "OK", vmu->accountcode ); - fprintf(txt, logbuf); + fprintf(txt, "%s", logbuf); if (minivmlogfile) { ast_mutex_lock(&minivmloglock); - fprintf(minivmlogfile, logbuf); + fprintf(minivmlogfile, "%s", logbuf); ast_mutex_unlock(&minivmloglock); } @@ -2474,7 +2474,7 @@ static int load_config(int reload) static char *handle_minivm_list_templates(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_template *this; - char *output_format = "%-15s %-10s %-10s %-15.15s %-50s\n"; +#define HVLT_OUTPUT_FORMAT "%-15s %-10s %-10s %-15.15s %-50s\n" int count = 0; switch (cmd) { @@ -2497,10 +2497,10 @@ static char *handle_minivm_list_templates(struct ast_cli_entry *e, int cmd, stru AST_LIST_UNLOCK(&message_templates); return CLI_FAILURE; } - ast_cli(a->fd, output_format, "Template name", "Charset", "Locale", "Attach media", "Subject"); - ast_cli(a->fd, output_format, "-------------", "-------", "------", "------------", "-------"); + ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "Template name", "Charset", "Locale", "Attach media", "Subject"); + ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "-------------", "-------", "------", "------------", "-------"); AST_LIST_TRAVERSE(&message_templates, this, list) { - ast_cli(a->fd, output_format, this->name, + ast_cli(a->fd, HVLT_OUTPUT_FORMAT, this->name, this->charset ? this->charset : "-", this->locale ? this->locale : "-", this->attachment ? "Yes" : "No", @@ -2540,7 +2540,7 @@ static char *complete_minivm_show_users(const char *line, const char *word, int static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_account *vmu; - char *output_format = "%-23s %-15s %-15s %-10s %-10s %-50s\n"; +#define HMSU_OUTPUT_FORMAT "%-23s %-15s %-15s %-10s %-10s %-50s\n" int count = 0; switch (cmd) { @@ -2565,14 +2565,14 @@ static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct a AST_LIST_UNLOCK(&minivm_accounts); return CLI_FAILURE; } - ast_cli(a->fd, output_format, "User", "E-Template", "P-template", "Zone", "Format", "Full name"); - ast_cli(a->fd, output_format, "----", "----------", "----------", "----", "------", "---------"); + ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "User", "E-Template", "P-template", "Zone", "Format", "Full name"); + ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "----", "----------", "----------", "----", "------", "---------"); AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) { char tmp[256] = ""; if ((a->argc == 3) || ((a->argc == 5) && !strcmp(a->argv[4], vmu->domain))) { count++; snprintf(tmp, sizeof(tmp), "%s@%s", vmu->username, vmu->domain); - ast_cli(a->fd, output_format, tmp, vmu->etemplate ? vmu->etemplate : "-", + ast_cli(a->fd, HMSU_OUTPUT_FORMAT, tmp, vmu->etemplate ? vmu->etemplate : "-", vmu->ptemplate ? vmu->ptemplate : "-", vmu->zonetag ? vmu->zonetag : "-", vmu->attachfmt ? vmu->attachfmt : "-", @@ -2588,7 +2588,7 @@ static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct a static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_zone *zone; - char *output_format = "%-15s %-20s %-45s\n"; +#define HMSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" char *res = CLI_SUCCESS; switch (cmd) { @@ -2607,10 +2607,10 @@ static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct a AST_LIST_LOCK(&minivm_zones); if (!AST_LIST_EMPTY(&minivm_zones)) { - ast_cli(a->fd, output_format, "Zone", "Timezone", "Message Format"); - ast_cli(a->fd, output_format, "----", "--------", "--------------"); + ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format"); + ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "----", "--------", "--------------"); AST_LIST_TRAVERSE(&minivm_zones, zone, list) { - ast_cli(a->fd, output_format, zone->name, zone->timezone, zone->msg_format); + ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format); } } else { ast_cli(a->fd, "There are no voicemail zones currently defined\n"); diff --git a/apps/app_queue.c b/apps/app_queue.c index 7a4638c8f..ca109f9b6 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1233,13 +1233,13 @@ static void queue_set_param(struct call_queue *q, const char *param, const char while ((s = strsep(&buf, ",|"))) { if (!q->sound_periodicannounce[i]) q->sound_periodicannounce[i] = ast_str_create(16); - ast_str_set(&q->sound_periodicannounce[i], 0, s); + ast_str_set(&q->sound_periodicannounce[i], 0, "%s", s); i++; if (i == MAX_PERIODIC_ANNOUNCEMENTS) break; } } else { - ast_str_set(&q->sound_periodicannounce[0], 0, val); + ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val); } } else if (!strcasecmp(param, "periodic-announce-frequency")) { q->periodicannouncefrequency = atoi(val); diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 2a4f496b7..d0b8cc3ba 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -645,7 +645,6 @@ static char *pagerbody = NULL; static char *pagersubject = NULL; static char fromstring[100]; static char pagerfromstring[100]; -static char emailtitle[100]; static char charset[32] = "ISO-8859-1"; static unsigned char adsifdn[4] = "\x00\x00\x00\x0F"; @@ -2021,9 +2020,6 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in ast_channel_free(ast); } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); - } else if (!ast_strlen_zero(emailtitle)) { - fprintf(p, emailtitle, msgnum + 1, mailbox) ; - fprintf(p, ENDL) ; } else if (ast_test_flag((&globalflags), VM_PBXSKIP)) fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); else @@ -7784,7 +7780,7 @@ static char *complete_voicemail_show_users(const char *line, const char *word, i static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_vm_user *vmu; - char *output_format = "%-10s %-5s %-25s %-10s %6s\n"; +#define HVSU_OUTPUT_FORMAT "%-10s %-5s %-25s %-10s %6s\n" const char *context = NULL; int users_counter = 0; @@ -7822,7 +7818,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc return CLI_FAILURE; } if (a->argc == 3) - ast_cli(a->fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg"); + ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); else { int count = 0; AST_LIST_TRAVERSE(&users, vmu, list) { @@ -7830,7 +7826,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc count++; } if (count) { - ast_cli(a->fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg"); + ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); } else { ast_cli(a->fd, "No such voicemail context \"%s\"\n", context); AST_LIST_UNLOCK(&users); @@ -7845,7 +7841,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context); inboxcount(tmp, &newmsgs, &oldmsgs); snprintf(count, sizeof(count), "%d", newmsgs); - ast_cli(a->fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count); + ast_cli(a->fd, HVSU_OUTPUT_FORMAT, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count); users_counter++; } } @@ -7858,7 +7854,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct vm_zone *zone; - char *output_format = "%-15s %-20s %-45s\n"; +#define HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" char *res = CLI_SUCCESS; switch (cmd) { @@ -7877,9 +7873,9 @@ static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struc AST_LIST_LOCK(&zones); if (!AST_LIST_EMPTY(&zones)) { - ast_cli(a->fd, output_format, "Zone", "Timezone", "Message Format"); + ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format"); AST_LIST_TRAVERSE(&zones, zone, list) { - ast_cli(a->fd, output_format, zone->name, zone->timezone, zone->msg_format); + ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format); } } else { ast_cli(a->fd, "There are no voicemail zones currently defined\n"); @@ -8706,7 +8702,6 @@ static int load_config(int reload) } memset(fromstring, 0, sizeof(fromstring)); memset(pagerfromstring, 0, sizeof(pagerfromstring)); - memset(emailtitle, 0, sizeof(emailtitle)); strcpy(charset, "ISO-8859-1"); if (emailbody) { ast_free(emailbody); @@ -8744,13 +8739,10 @@ static int load_config(int reload) memcpy(&adsisec[x], &tmpadsi[x], 1); } } - if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) + if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) { if (atoi(val)) { adsiver = atoi(val); } - if ((val = ast_variable_retrieve(cfg, "general", "emailtitle"))) { - ast_log(LOG_NOTICE, "Keyword 'emailtitle' is DEPRECATED, please use 'emailsubject' instead.\n"); - ast_copy_string(emailtitle, val, sizeof(emailtitle)); } if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) emailsubject = ast_strdup(val); |