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: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@109459 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Russell Bryant 18 years ago
parent 1df02c7c33
commit 4af367c3a9

@ -229,7 +229,7 @@ ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
ifeq ($(AST_DEVMODE),yes) ifeq ($(AST_DEVMODE),yes)
ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
endif endif
ifneq ($(findstring BSD,$(OSARCH)),) ifneq ($(findstring BSD,$(OSARCH)),)

@ -327,11 +327,21 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) { if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) {
cachedir = "/tmp/"; cachedir = "/tmp/";
} }
data = ast_strdupa(vdata);
AST_STANDARD_APP_ARGS(args, data);
if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) { 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 */ } else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
int i, j; 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++) { for (i = 0, j = 0; i < strlen(festivalcommand); i++) {
if (festivalcommand[i] == '\\' && festivalcommand[i + 1] == 'n') { 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] == '\\') { } else if (festivalcommand[i] == '\\') {
newfestivalcommand[j++] = festivalcommand[i + 1]; newfestivalcommand[j++] = festivalcommand[i + 1];
i++; 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 } else
newfestivalcommand[j++] = festivalcommand[i]; newfestivalcommand[j++] = festivalcommand[i];
} }
@ -347,9 +361,6 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
festivalcommand = newfestivalcommand; festivalcommand = newfestivalcommand;
} }
data = ast_strdupa(vdata);
AST_STANDARD_APP_ARGS(args, data);
if (args.interrupt && !strcasecmp(args.interrupt, "any")) if (args.interrupt && !strcasecmp(args.interrupt, "any"))
args.interrupt = AST_DIGIT_ANY; args.interrupt = AST_DIGIT_ANY;
@ -440,7 +451,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
} else { } else {
ast_debug(1, "Passing text to festival...\n"); ast_debug(1, "Passing text to festival...\n");
fs = fdopen(dup(fd), "wb"); fs = fdopen(dup(fd), "wb");
fprintf(fs, festivalcommand, args.text);
fprintf(fs, "%s", festivalcommand);
fflush(fs); fflush(fs);
fclose(fs); fclose(fs);
} }

@ -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 hr, min, sec;
int i = 0, total = 0; int i = 0, total = 0;
time_t now; 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] = ""; 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) { switch (cmd) {
case CLI_INIT: 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; return CLI_SUCCESS;
} }
if (!concise) 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) { AST_LIST_TRAVERSE(&confs, cnf, list) {
if (cnf->markedusers == 0) if (cnf->markedusers == 0)
strcpy(cmdline, "N/A "); 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; min = ((now - cnf->start) % 3600) / 60;
sec = (now - cnf->start) % 60; sec = (now - cnf->start) % 60;
if (!concise) 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 { else {
ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n", ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n",
cnf->confno, cnf->confno,

@ -1560,10 +1560,10 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
duration < global_vmminmessage ? "IGNORED" : "OK", duration < global_vmminmessage ? "IGNORED" : "OK",
vmu->accountcode vmu->accountcode
); );
fprintf(txt, logbuf); fprintf(txt, "%s", logbuf);
if (minivmlogfile) { if (minivmlogfile) {
ast_mutex_lock(&minivmloglock); ast_mutex_lock(&minivmloglock);
fprintf(minivmlogfile, logbuf); fprintf(minivmlogfile, "%s", logbuf);
ast_mutex_unlock(&minivmloglock); 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) static char *handle_minivm_list_templates(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct minivm_template *this; 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; int count = 0;
switch (cmd) { 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); AST_LIST_UNLOCK(&message_templates);
return CLI_FAILURE; return CLI_FAILURE;
} }
ast_cli(a->fd, output_format, "Template name", "Charset", "Locale", "Attach media", "Subject"); ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "Template name", "Charset", "Locale", "Attach media", "Subject");
ast_cli(a->fd, output_format, "-------------", "-------", "------", "------------", "-------"); ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "-------------", "-------", "------", "------------", "-------");
AST_LIST_TRAVERSE(&message_templates, this, list) { 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->charset ? this->charset : "-",
this->locale ? this->locale : "-", this->locale ? this->locale : "-",
this->attachment ? "Yes" : "No", 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) static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct minivm_account *vmu; 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; int count = 0;
switch (cmd) { 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); AST_LIST_UNLOCK(&minivm_accounts);
return CLI_FAILURE; return CLI_FAILURE;
} }
ast_cli(a->fd, output_format, "User", "E-Template", "P-template", "Zone", "Format", "Full name"); ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "User", "E-Template", "P-template", "Zone", "Format", "Full name");
ast_cli(a->fd, output_format, "----", "----------", "----------", "----", "------", "---------"); ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "----", "----------", "----------", "----", "------", "---------");
AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) { AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) {
char tmp[256] = ""; char tmp[256] = "";
if ((a->argc == 3) || ((a->argc == 5) && !strcmp(a->argv[4], vmu->domain))) { if ((a->argc == 3) || ((a->argc == 5) && !strcmp(a->argv[4], vmu->domain))) {
count++; count++;
snprintf(tmp, sizeof(tmp), "%s@%s", vmu->username, vmu->domain); 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->ptemplate ? vmu->ptemplate : "-",
vmu->zonetag ? vmu->zonetag : "-", vmu->zonetag ? vmu->zonetag : "-",
vmu->attachfmt ? vmu->attachfmt : "-", 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) static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct minivm_zone *zone; struct minivm_zone *zone;
char *output_format = "%-15s %-20s %-45s\n"; #define HMSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n"
char *res = CLI_SUCCESS; char *res = CLI_SUCCESS;
switch (cmd) { 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); AST_LIST_LOCK(&minivm_zones);
if (!AST_LIST_EMPTY(&minivm_zones)) { if (!AST_LIST_EMPTY(&minivm_zones)) {
ast_cli(a->fd, output_format, "Zone", "Timezone", "Message Format"); ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format");
ast_cli(a->fd, output_format, "----", "--------", "--------------"); ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "----", "--------", "--------------");
AST_LIST_TRAVERSE(&minivm_zones, zone, list) { 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 { } else {
ast_cli(a->fd, "There are no voicemail zones currently defined\n"); ast_cli(a->fd, "There are no voicemail zones currently defined\n");

@ -1233,13 +1233,13 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
while ((s = strsep(&buf, ",|"))) { while ((s = strsep(&buf, ",|"))) {
if (!q->sound_periodicannounce[i]) if (!q->sound_periodicannounce[i])
q->sound_periodicannounce[i] = ast_str_create(16); 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++; i++;
if (i == MAX_PERIODIC_ANNOUNCEMENTS) if (i == MAX_PERIODIC_ANNOUNCEMENTS)
break; break;
} }
} else { } 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")) { } else if (!strcasecmp(param, "periodic-announce-frequency")) {
q->periodicannouncefrequency = atoi(val); q->periodicannouncefrequency = atoi(val);

@ -645,7 +645,6 @@ static char *pagerbody = NULL;
static char *pagersubject = NULL; static char *pagersubject = NULL;
static char fromstring[100]; static char fromstring[100];
static char pagerfromstring[100]; static char pagerfromstring[100];
static char emailtitle[100];
static char charset[32] = "ISO-8859-1"; static char charset[32] = "ISO-8859-1";
static unsigned char adsifdn[4] = "\x00\x00\x00\x0F"; 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); ast_channel_free(ast);
} else } else
ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 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)) } else if (ast_test_flag((&globalflags), VM_PBXSKIP))
fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox);
else 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) static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct ast_vm_user *vmu; 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; const char *context = NULL;
int users_counter = 0; 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; return CLI_FAILURE;
} }
if (a->argc == 3) 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 { else {
int count = 0; int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) { 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++; count++;
} }
if (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 { } else {
ast_cli(a->fd, "No such voicemail context \"%s\"\n", context); ast_cli(a->fd, "No such voicemail context \"%s\"\n", context);
AST_LIST_UNLOCK(&users); 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); snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs); inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count, sizeof(count), "%d", newmsgs); 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++; 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) static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct vm_zone *zone; struct vm_zone *zone;
char *output_format = "%-15s %-20s %-45s\n"; #define HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n"
char *res = CLI_SUCCESS; char *res = CLI_SUCCESS;
switch (cmd) { switch (cmd) {
@ -7877,9 +7873,9 @@ static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struc
AST_LIST_LOCK(&zones); AST_LIST_LOCK(&zones);
if (!AST_LIST_EMPTY(&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_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 { } else {
ast_cli(a->fd, "There are no voicemail zones currently defined\n"); 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(fromstring, 0, sizeof(fromstring));
memset(pagerfromstring, 0, sizeof(pagerfromstring)); memset(pagerfromstring, 0, sizeof(pagerfromstring));
memset(emailtitle, 0, sizeof(emailtitle));
strcpy(charset, "ISO-8859-1"); strcpy(charset, "ISO-8859-1");
if (emailbody) { if (emailbody) {
ast_free(emailbody); ast_free(emailbody);
@ -8744,13 +8739,10 @@ static int load_config(int reload)
memcpy(&adsisec[x], &tmpadsi[x], 1); 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)) { if (atoi(val)) {
adsiver = 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"))) if ((val = ast_variable_retrieve(cfg, "general", "emailsubject")))
emailsubject = ast_strdup(val); emailsubject = ast_strdup(val);

@ -102,7 +102,7 @@ static int load_column_config(const char *tmp)
return -1; return -1;
} }
if (!column_string->used) if (!column_string->used)
ast_str_set(&column_string, 0, escaped); ast_str_set(&column_string, 0, "%s", escaped);
else else
ast_str_append(&column_string, 0, ",%s", escaped); ast_str_append(&column_string, 0, ",%s", escaped);
sqlite3_free(escaped); sqlite3_free(escaped);

@ -788,7 +788,7 @@ static void iax_error_output(const char *data)
ast_log(LOG_WARNING, "%s", data); ast_log(LOG_WARNING, "%s", data);
} }
static void jb_error_output(const char *fmt, ...) static void __attribute__((format (printf, 1, 2))) jb_error_output(const char *fmt, ...)
{ {
va_list args; va_list args;
char buf[1024]; char buf[1024];
@ -797,10 +797,10 @@ static void jb_error_output(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, args); vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args); va_end(args);
ast_log(LOG_ERROR, buf); ast_log(LOG_ERROR, "%s", buf);
} }
static void jb_warning_output(const char *fmt, ...) static void __attribute__((format (printf, 1, 2))) jb_warning_output(const char *fmt, ...)
{ {
va_list args; va_list args;
char buf[1024]; char buf[1024];
@ -809,10 +809,10 @@ static void jb_warning_output(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, args); vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args); va_end(args);
ast_log(LOG_WARNING, buf); ast_log(LOG_WARNING, "%s", buf);
} }
static void jb_debug_output(const char *fmt, ...) static void __attribute__((format (printf, 1, 2))) jb_debug_output(const char *fmt, ...)
{ {
va_list args; va_list args;
char buf[1024]; char buf[1024];
@ -821,7 +821,7 @@ static void jb_debug_output(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, args); vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args); va_end(args);
ast_verbose(buf); ast_verbose("%s", buf);
} }
/*! /*!
@ -5173,11 +5173,12 @@ static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
{ {
int x; int x;
int numchans = 0; int numchans = 0;
#define ACN_FORMAT1 "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n"
#define ACN_FORMAT2 "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"
for (x=0;x<IAX_MAX_CALLS;x++) { for (x=0;x<IAX_MAX_CALLS;x++) {
ast_mutex_lock(&iaxsl[x]); ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) { if (iaxs[x]) {
int localjitter, localdelay, locallost, locallosspct, localdropped, localooo; int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
char *fmt;
jb_info jbinfo; jb_info jbinfo;
if(ast_test_flag(iaxs[x], IAX_USEJITTERBUF)) { if(ast_test_flag(iaxs[x], IAX_USEJITTERBUF)) {
@ -5196,13 +5197,9 @@ static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
localdropped = 0; localdropped = 0;
localooo = -1; localooo = -1;
} }
if (limit_fmt)
fmt = "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n";
else
fmt = "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n";
if (s) if (s)
astman_append(s, fmt, astman_append(s, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
iaxs[x]->owner ? iaxs[x]->owner->name : "(None)", iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
iaxs[x]->pingtime, iaxs[x]->pingtime,
localjitter, localjitter,
@ -5220,7 +5217,7 @@ static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt)
iaxs[x]->remote_rr.ooo, iaxs[x]->remote_rr.ooo,
iaxs[x]->remote_rr.packets/1000); iaxs[x]->remote_rr.packets/1000);
else else
ast_cli(fd, fmt, ast_cli(fd, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
iaxs[x]->owner ? iaxs[x]->owner->name : "(None)", iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
iaxs[x]->pingtime, iaxs[x]->pingtime,
localjitter, localjitter,

@ -5709,7 +5709,7 @@ void chan_misdn_log(int level, int port, char *tmpl, ...)
va_end(ap); va_end(ap);
if (level == -1) if (level == -1)
ast_log(LOG_WARNING, buf); ast_log(LOG_WARNING, "%s", buf);
else if (misdn_debug_only[port] ? else if (misdn_debug_only[port] ?
(level == 1 && misdn_debug[port]) || (level == misdn_debug[port]) (level == 1 && misdn_debug[port]) || (level == misdn_debug[port])

@ -2623,7 +2623,7 @@ static void ast_sip_ouraddrfor(struct in_addr *them, struct sockaddr_in *us)
} }
/*! \brief Append to SIP dialog history with arg list */ /*! \brief Append to SIP dialog history with arg list */
static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap) static __attribute__((format (printf, 2, 0))) void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
{ {
char buf[80], *c = buf; /* max history length */ char buf[80], *c = buf; /* max history length */
struct sip_history *hist; struct sip_history *hist;

@ -67,14 +67,14 @@ static int function_enum(struct ast_channel *chan, const char *cmd, char *data,
buf[0] = '\0'; buf[0] = '\0';
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, synopsis); ast_log(LOG_WARNING, "%s", synopsis);
return -1; return -1;
} }
AST_STANDARD_APP_ARGS(args, data); AST_STANDARD_APP_ARGS(args, data);
if (args.argc < 1) { if (args.argc < 1) {
ast_log(LOG_WARNING, synopsis); ast_log(LOG_WARNING, "%s", synopsis);
return -1; return -1;
} }

@ -810,7 +810,7 @@ extern "C" {
* descriptor. * descriptor.
*/ */
#define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \ #define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \
ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0)) ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, "%s", s); } while(0))
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
} }

@ -218,7 +218,7 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attri
\param fmt printf-style format string \param fmt printf-style format string
\param ap varargs list of arguments for format \param ap varargs list of arguments for format
*/ */
int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap); int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format (printf, 3, 0)));
/*! /*!
* \brief Make sure something is true. * \brief Make sure something is true.

@ -554,6 +554,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
AST_INLINE_API( AST_INLINE_API(
__attribute__((format (printf, 5, 6)))
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...), int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...),
{ {
int res; int res;
@ -580,6 +581,7 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
AST_INLINE_API( AST_INLINE_API(
__attribute__((format (printf, 5, 0)))
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
{ {
int res; int res;

@ -163,7 +163,7 @@ enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats);
/*! \brief set jitterbuf conf */ /*! \brief set jitterbuf conf */
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf); enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
typedef void (*jb_output_function_t)(const char *fmt, ...); typedef void __attribute__((format (printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...);
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
#ifdef __cplusplus #ifdef __cplusplus

@ -1373,7 +1373,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
close(ast_consock); close(ast_consock);
if (!ast_opt_remote) if (!ast_opt_remote)
unlink(ast_config_AST_PID); unlink(ast_config_AST_PID);
printf(term_quit()); printf("%s", term_quit());
if (restart) { if (restart) {
if (option_verbose || ast_opt_console) if (option_verbose || ast_opt_console)
ast_verbose("Preparing for Asterisk restart...\n"); ast_verbose("Preparing for Asterisk restart...\n");
@ -1458,7 +1458,7 @@ static int ast_all_zeros(char *s)
static void consolehandler(char *s) static void consolehandler(char *s)
{ {
printf(term_end()); printf("%s", term_end());
fflush(stdout); fflush(stdout);
/* Called when readline data is available */ /* Called when readline data is available */
@ -1906,7 +1906,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
for (tries = 0; tries < 30 * reconnects_per_second; tries++) { for (tries = 0; tries < 30 * reconnects_per_second; tries++) {
if (ast_tryconnect()) { if (ast_tryconnect()) {
fprintf(stderr, "Reconnect succeeded after %.3f seconds\n", 1.0 / reconnects_per_second * tries); fprintf(stderr, "Reconnect succeeded after %.3f seconds\n", 1.0 / reconnects_per_second * tries);
printf(term_quit()); printf("%s", term_quit());
WELCOME_MESSAGE; WELCOME_MESSAGE;
if (!ast_opt_mute) if (!ast_opt_mute)
fdprint(ast_consock, "logger mute silent"); fdprint(ast_consock, "logger mute silent");
@ -3086,7 +3086,7 @@ int main(int argc, char *argv[])
#endif #endif
ast_term_init(); ast_term_init();
printf(term_end()); printf("%s", term_end());
fflush(stdout); fflush(stdout);
if (ast_opt_console && !option_verbose) if (ast_opt_console && !option_verbose)
@ -3111,18 +3111,18 @@ int main(int argc, char *argv[])
quit_handler(0, 0, 0, 0); quit_handler(0, 0, 0, 0);
exit(0); exit(0);
} }
printf(term_quit()); printf("%s", term_quit());
ast_remotecontrol(NULL); ast_remotecontrol(NULL);
quit_handler(0, 0, 0, 0); quit_handler(0, 0, 0, 0);
exit(0); exit(0);
} else { } else {
ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", ast_config_AST_SOCKET); ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", ast_config_AST_SOCKET);
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
} else if (ast_opt_remote || ast_opt_exec) { } else if (ast_opt_remote || ast_opt_exec) {
ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n", ast_config_AST_SOCKET); ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n", ast_config_AST_SOCKET);
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
/* Blindly write pid file since we couldn't connect */ /* Blindly write pid file since we couldn't connect */
@ -3180,7 +3180,7 @@ int main(int argc, char *argv[])
initstate((unsigned int) getpid() * 65536 + (unsigned int) time(NULL), randompool, sizeof(randompool)); initstate((unsigned int) getpid() * 65536 + (unsigned int) time(NULL), randompool, sizeof(randompool));
if (init_logger()) { /* Start logging subsystem */ if (init_logger()) { /* Start logging subsystem */
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
@ -3191,12 +3191,12 @@ int main(int argc, char *argv[])
ast_autoservice_init(); ast_autoservice_init();
if (load_modules(1)) { /* Load modules, pre-load only */ if (load_modules(1)) { /* Load modules, pre-load only */
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (dnsmgr_init()) { /* Initialize the DNS manager */ if (dnsmgr_init()) { /* Initialize the DNS manager */
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
@ -3205,17 +3205,17 @@ int main(int argc, char *argv[])
ast_channels_init(); ast_channels_init();
if (init_manager()) { if (init_manager()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (ast_cdr_engine_init()) { if (ast_cdr_engine_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (ast_device_state_engine_init()) { if (ast_device_state_engine_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
@ -3224,39 +3224,39 @@ int main(int argc, char *argv[])
ast_udptl_init(); ast_udptl_init();
if (ast_image_init()) { if (ast_image_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (ast_file_init()) { if (ast_file_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (load_pbx()) { if (load_pbx()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
ast_features_init(); ast_features_init();
if (init_framer()) { if (init_framer()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (astdb_init()) { if (astdb_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (ast_enum_init()) { if (ast_enum_init()) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
if (load_modules(0)) { if (load_modules(0)) {
printf(term_quit()); printf("%s", term_quit());
exit(1); exit(1);
} }
@ -3267,7 +3267,7 @@ int main(int argc, char *argv[])
if (ast_opt_console && !option_verbose) if (ast_opt_console && !option_verbose)
ast_verbose(" ]\n"); ast_verbose(" ]\n");
if (option_verbose || ast_opt_console) if (option_verbose || ast_opt_console)
ast_verbose(term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp))); ast_verbose("%s", term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp)));
if (ast_opt_no_fork) if (ast_opt_no_fork)
consolethread = pthread_self(); consolethread = pthread_self();

@ -878,7 +878,7 @@ static char *handle_commandcomplete(struct ast_cli_entry *e, int cmd, struct ast
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
buf = __ast_cli_generator(a->argv[2], a->argv[3], atoi(a->argv[4]), 0); buf = __ast_cli_generator(a->argv[2], a->argv[3], atoi(a->argv[4]), 0);
if (buf) { if (buf) {
ast_cli(a->fd, buf); ast_cli(a->fd, "%s", buf);
ast_free(buf); ast_free(buf);
} else } else
ast_cli(a->fd, "NULL\n"); ast_cli(a->fd, "NULL\n");

@ -2850,7 +2850,7 @@ static char *handle_feature_show(struct ast_cli_entry *e, int cmd, struct ast_cl
{ {
int i; int i;
struct ast_call_feature *feature; struct ast_call_feature *feature;
char format[] = "%-25s %-7s %-7s\n"; #define HFS_FORMAT "%-25s %-7s %-7s\n"
switch (cmd) { switch (cmd) {
@ -2864,25 +2864,25 @@ static char *handle_feature_show(struct ast_cli_entry *e, int cmd, struct ast_cl
return NULL; return NULL;
} }
ast_cli(a->fd, format, "Builtin Feature", "Default", "Current"); ast_cli(a->fd, HFS_FORMAT, "Builtin Feature", "Default", "Current");
ast_cli(a->fd, format, "---------------", "-------", "-------"); ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
ast_cli(a->fd, format, "Pickup", "*8", ast_pickup_ext()); /* default hardcoded above, so we'll hardcode it here */ ast_cli(a->fd, HFS_FORMAT, "Pickup", "*8", ast_pickup_ext()); /* default hardcoded above, so we'll hardcode it here */
ast_rwlock_rdlock(&features_lock); ast_rwlock_rdlock(&features_lock);
for (i = 0; i < FEATURES_COUNT; i++) for (i = 0; i < FEATURES_COUNT; i++)
ast_cli(a->fd, format, builtin_features[i].fname, builtin_features[i].default_exten, builtin_features[i].exten); ast_cli(a->fd, HFS_FORMAT, builtin_features[i].fname, builtin_features[i].default_exten, builtin_features[i].exten);
ast_rwlock_unlock(&features_lock); ast_rwlock_unlock(&features_lock);
ast_cli(a->fd, "\n"); ast_cli(a->fd, "\n");
ast_cli(a->fd, format, "Dynamic Feature", "Default", "Current"); ast_cli(a->fd, HFS_FORMAT, "Dynamic Feature", "Default", "Current");
ast_cli(a->fd, format, "---------------", "-------", "-------"); ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
if (AST_LIST_EMPTY(&feature_list)) if (AST_LIST_EMPTY(&feature_list))
ast_cli(a->fd, "(none)\n"); ast_cli(a->fd, "(none)\n");
else { else {
AST_LIST_LOCK(&feature_list); AST_LIST_LOCK(&feature_list);
AST_LIST_TRAVERSE(&feature_list, feature, feature_entry) AST_LIST_TRAVERSE(&feature_list, feature, feature_entry)
ast_cli(a->fd, format, feature->sname, "no def", feature->exten); ast_cli(a->fd, HFS_FORMAT, feature->sname, "no def", feature->exten);
AST_LIST_UNLOCK(&feature_list); AST_LIST_UNLOCK(&feature_list);
} }
ast_cli(a->fd, "\nCall parking\n"); ast_cli(a->fd, "\nCall parking\n");

@ -560,7 +560,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now,
/* if a hard clamp was requested, use it */ /* if a hard clamp was requested, use it */
if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) { if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) {
jb_dbg("clamping target from %d to %d\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf); jb_dbg("clamping target from %ld to %ld\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf);
jb->info.target = jb->info.min + jb->info.conf.max_jitterbuf; jb->info.target = jb->info.min + jb->info.conf.max_jitterbuf;
} }

@ -643,7 +643,7 @@ static char *handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli
{ {
struct manager_action *cur; struct manager_action *cur;
struct ast_str *authority; struct ast_str *authority;
static const char *format = " %-15.15s %-15.15s %-55.55s\n"; #define HSMC_FORMAT " %-15.15s %-15.15s %-55.55s\n"
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "manager show commands"; e->command = "manager show commands";
@ -655,12 +655,12 @@ static char *handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli
return NULL; return NULL;
} }
authority = ast_str_alloca(80); authority = ast_str_alloca(80);
ast_cli(a->fd, format, "Action", "Privilege", "Synopsis"); ast_cli(a->fd, HSMC_FORMAT, "Action", "Privilege", "Synopsis");
ast_cli(a->fd, format, "------", "---------", "--------"); ast_cli(a->fd, HSMC_FORMAT, "------", "---------", "--------");
AST_RWLIST_RDLOCK(&actions); AST_RWLIST_RDLOCK(&actions);
AST_RWLIST_TRAVERSE(&actions, cur, list) AST_RWLIST_TRAVERSE(&actions, cur, list)
ast_cli(a->fd, format, cur->action, authority_to_str(cur->authority, &authority), cur->synopsis); ast_cli(a->fd, HSMC_FORMAT, cur->action, authority_to_str(cur->authority, &authority), cur->synopsis);
AST_RWLIST_UNLOCK(&actions); AST_RWLIST_UNLOCK(&actions);
return CLI_SUCCESS; return CLI_SUCCESS;
@ -671,8 +671,8 @@ static char *handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli
{ {
struct mansession *s; struct mansession *s;
time_t now = time(NULL); time_t now = time(NULL);
static const char *format = " %-15.15s %-15.15s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"; #define HSMCONN_FORMAT1 " %-15.15s %-15.15s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"
static const char *format2 = " %-15.15s %-15.15s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n"; #define HSMCONN_FORMAT2 " %-15.15s %-15.15s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n"
int count = 0; int count = 0;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
@ -686,11 +686,11 @@ static char *handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli
return NULL; return NULL;
} }
ast_cli(a->fd, format, "Username", "IP Address", "Start", "Elapsed", "FileDes", "HttpCnt", "Read", "Write"); ast_cli(a->fd, HSMCONN_FORMAT1, "Username", "IP Address", "Start", "Elapsed", "FileDes", "HttpCnt", "Read", "Write");
AST_LIST_LOCK(&sessions); AST_LIST_LOCK(&sessions);
AST_LIST_TRAVERSE(&sessions, s, list) { AST_LIST_TRAVERSE(&sessions, s, list) {
ast_cli(a->fd, format2, s->username, ast_inet_ntoa(s->sin.sin_addr), (int)(s->sessionstart), (int)(now - s->sessionstart), s->fd, s->inuse, s->readperm, s->writeperm); ast_cli(a->fd, HSMCONN_FORMAT2, s->username, ast_inet_ntoa(s->sin.sin_addr), (int)(s->sessionstart), (int)(now - s->sessionstart), s->fd, s->inuse, s->readperm, s->writeperm);
count++; count++;
} }
AST_LIST_UNLOCK(&sessions); AST_LIST_UNLOCK(&sessions);
@ -3520,7 +3520,7 @@ static struct ast_str *generic_http_callback(enum output_format format,
if (format == FORMAT_XML || format == FORMAT_HTML) if (format == FORMAT_XML || format == FORMAT_HTML)
xml_translate(&out, buf, params, format); xml_translate(&out, buf, params, format);
else else
ast_str_append(&out, 0, buf); ast_str_append(&out, 0, "%s", buf);
munmap(buf, l); munmap(buf, l);
} }
} else if (format == FORMAT_XML || format == FORMAT_HTML) { } else if (format == FORMAT_XML || format == FORMAT_HTML) {

@ -592,7 +592,7 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd,
} }
} }
ast_str_append(&out, -1, "\n"); ast_str_append(&out, -1, "\n");
ast_cli(a->fd, out->str); ast_cli(a->fd, "%s", out->str);
} }
AST_RWLIST_UNLOCK(&translators); AST_RWLIST_UNLOCK(&translators);
return CLI_SUCCESS; return CLI_SUCCESS;

@ -1349,6 +1349,7 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr
return result; return result;
} }
__attribute((format (printf, 4, 0)))
void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2) const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2)
@ -1380,6 +1381,7 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
mgr->used += needed; mgr->used += needed;
} }
__attribute((format (printf, 4, 5)))
void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, ...) const ast_string_field *ptr, const char *format, ...)
@ -1470,6 +1472,8 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
* ast_str_set_va(...) * ast_str_set_va(...)
* ast_str_append_va(...) * ast_str_append_va(...)
*/ */
__attribute__((format (printf, 4, 0)))
int __ast_str_helper(struct ast_str **buf, size_t max_len, int __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap) int append, const char *fmt, va_list ap)
{ {

@ -2721,7 +2721,7 @@ static char *handle_cli_agi_show(struct ast_cli_entry *e, int cmd, struct ast_cl
if (a->argc > e->args) { if (a->argc > e->args) {
command = find_command(a->argv + e->args, 1); command = find_command(a->argv + e->args, 1);
if (command) { if (command) {
ast_cli(a->fd, command->usage); ast_cli(a->fd, "%s", command->usage);
ast_cli(a->fd, " Runs Dead : %s\n", command->dead ? "Yes" : "No"); ast_cli(a->fd, " Runs Dead : %s\n", command->dead ? "Yes" : "No");
} else { } else {
if (find_command(a->argv + e->args, -1)) { if (find_command(a->argv + e->args, -1)) {

@ -766,10 +766,10 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p
ast_str_append(&filter, 0, "(&"); ast_str_append(&filter, 0, "(&");
if (table_config && table_config->additional_filter) if (table_config && table_config->additional_filter)
ast_str_append(&filter, 0, table_config->additional_filter); ast_str_append(&filter, 0, "%s", table_config->additional_filter);
if (table_config != base_table_config && base_table_config && if (table_config != base_table_config && base_table_config &&
base_table_config->additional_filter) { base_table_config->additional_filter) {
ast_str_append(&filter, 0, base_table_config->additional_filter); ast_str_append(&filter, 0, "%s", base_table_config->additional_filter);
} }
/* Create the first part of the query using the first parameter/value pairs we just extracted */ /* Create the first part of the query using the first parameter/value pairs we just extracted */
@ -1171,11 +1171,11 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
/* Create the filter with the table additional filter and the parameter/value pairs we were given */ /* Create the filter with the table additional filter and the parameter/value pairs we were given */
ast_str_append(&filter, 0, "(&"); ast_str_append(&filter, 0, "(&");
if (table_config && table_config->additional_filter) { if (table_config && table_config->additional_filter) {
ast_str_append(&filter, 0, table_config->additional_filter); ast_str_append(&filter, 0, "%s", table_config->additional_filter);
} }
if (table_config != base_table_config && base_table_config if (table_config != base_table_config && base_table_config
&& base_table_config->additional_filter) { && base_table_config->additional_filter) {
ast_str_append(&filter, 0, base_table_config->additional_filter); ast_str_append(&filter, 0, "%s", base_table_config->additional_filter);
} }
append_var_and_value_to_filter(&filter, table_config, attribute, lookup); append_var_and_value_to_filter(&filter, table_config, attribute, lookup);
ast_str_append(&filter, 0, ")"); ast_str_append(&filter, 0, ")");

@ -202,7 +202,7 @@ static char *handle_cli_indication_show(struct ast_cli_entry *e, int cmd, struct
if (tz->nrringcadence) if (tz->nrringcadence)
j--; j--;
ast_copy_string(buf + j, "\n", sizeof(buf) - j); ast_copy_string(buf + j, "\n", sizeof(buf) - j);
ast_cli(a->fd, buf); ast_cli(a->fd, "%s", buf);
for (ts = tz->tones; ts; ts = ts->next) for (ts = tz->tones; ts; ts = ts->next)
ast_cli(a->fd, "%-7.7s %-15.15s %s\n", tz->country, ts->name, ts->data); ast_cli(a->fd, "%-7.7s %-15.15s %s\n", tz->country, ts->name, ts->data);
break; break;

@ -914,7 +914,7 @@ static int pp_each_user_exec(struct ast_channel *chan, const char *cmd, char *da
if (!ast_strlen_zero(args.exclude_mac) && !strcasecmp(user->macaddress, args.exclude_mac)) if (!ast_strlen_zero(args.exclude_mac) && !strcasecmp(user->macaddress, args.exclude_mac))
continue; continue;
pbx_substitute_variables_varshead(user->headp, args.string, expand_buf, sizeof(expand_buf)); pbx_substitute_variables_varshead(user->headp, args.string, expand_buf, sizeof(expand_buf));
ast_build_string(&buf, &len, expand_buf); ast_build_string(&buf, &len, "%s", expand_buf);
} }
AST_RWLIST_UNLOCK(&users); AST_RWLIST_UNLOCK(&users);

@ -42,7 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
char *header_format = "%30s %-30s\n"; #define CRL_HEADER_FORMAT "%30s %-30s\n"
struct ast_variable *var=NULL; struct ast_variable *var=NULL;
switch (cmd) { switch (cmd) {
@ -64,10 +64,10 @@ static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_
var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], NULL); var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], NULL);
if (var) { if (var) {
ast_cli(a->fd, header_format, "Column Name", "Column Value"); ast_cli(a->fd, CRL_HEADER_FORMAT, "Column Name", "Column Value");
ast_cli(a->fd, header_format, "--------------------", "--------------------"); ast_cli(a->fd, CRL_HEADER_FORMAT, "--------------------", "--------------------");
while (var) { while (var) {
ast_cli(a->fd, header_format, var->name, var->value); ast_cli(a->fd, CRL_HEADER_FORMAT, var->name, var->value);
var = var->next; var = var->next;
} }
} else { } else {

@ -141,7 +141,8 @@ static void del_chan(char *name)
AST_LIST_TRAVERSE_SAFE_END; AST_LIST_TRAVERSE_SAFE_END;
} }
static void fdprintf(int fd, char *fmt, ...)
static void __attribute__((format (printf, 2, 3))) fdprintf(int fd, char *fmt, ...)
{ {
char stuff[4096]; char stuff[4096];
va_list ap; va_list ap;
@ -406,7 +407,8 @@ static struct message *wait_for_response(int timeout)
return NULL; return NULL;
} }
static int manager_action(char *action, char *fmt, ...)
static int __attribute__((format (printf, 2, 3))) manager_action(char *action, char *fmt, ...)
{ {
struct ast_mansession *s; struct ast_mansession *s;
char tmp[4096]; char tmp[4096];
@ -465,7 +467,7 @@ static int hide_doing(void)
static void try_status(void) static void try_status(void)
{ {
struct message *m; struct message *m;
manager_action("Status", ""); manager_action("Status", "%s", "");
m = wait_for_response(10000); m = wait_for_response(10000);
if (!m) { if (!m) {
show_message("Status Failed", "Timeout waiting for response"); show_message("Status Failed", "Timeout waiting for response");

@ -40,7 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
* ast_str_set_va(...) * ast_str_set_va(...)
* ast_str_append_va(...) * ast_str_append_va(...)
*/ */
int __ast_str_helper(struct ast_str **buf, size_t max_len, int __attribute__((format (printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap) int append, const char *fmt, va_list ap)
{ {
int res, need; int res, need;

@ -338,6 +338,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
AST_INLINE_API( AST_INLINE_API(
__attribute__((format (printf, 5, 6)))
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...), int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...),
{ {
int res; int res;
@ -364,6 +365,7 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
AST_INLINE_API( AST_INLINE_API(
__attribute__((format (printf, 5, 0)))
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
{ {
int res; int res;
@ -2729,7 +2731,7 @@ static void ast_log(int level, const char *file, int line, const char *function,
va_end(vars); va_end(vars);
} }
static void ast_verbose(const char *fmt, ...) static void __attribute__((format (printf, 1, 2))) ast_verbose(const char *fmt, ...)
{ {
va_list vars; va_list vars;
va_start(vars,fmt); va_start(vars,fmt);

@ -910,7 +910,7 @@ int workloop( FILE *theinfile, FILE *theoutfile,
return TRUE; /* Input file done with, no errors. */ return TRUE; /* Input file done with, no errors. */
} }
int chat( const char *format, ...) int __attribute__((format (printf,1,2))) chat( const char *format, ...)
{ {
va_list ap; va_list ap;
int result = 0; int result = 0;
@ -924,8 +924,7 @@ int chat( const char *format, ...)
return result; return result;
} }
int __attribute__((format (printf,1,2))) inform( const char *format, ...)
int inform( const char *format, ...)
{ {
va_list ap; va_list ap;
int result = 0; int result = 0;
@ -939,7 +938,7 @@ int inform( const char *format, ...)
return result; return result;
} }
int error( const char *format, ...) int __attribute__((format (printf,1,2))) error( const char *format, ...)
{ {
va_list ap; va_list ap;
int result; int result;
@ -950,7 +949,7 @@ int error( const char *format, ...)
return result; return result;
} }
void fatalerror( const char *format, ...) void __attribute__((format (printf,1,2))) fatalerror( const char *format, ...)
{ {
va_list ap; va_list ap;
@ -966,7 +965,7 @@ void fatalperror( const char *string)
myexit( 1); myexit( 1);
} }
int say( const char *format, ...) int __attribute__((format (printf,1,2))) say( const char *format, ...)
{ {
va_list ap; va_list ap;
int result; int result;

Loading…
Cancel
Save