diff options
author | Terry Wilson <twilson@digium.com> | 2008-03-18 15:43:34 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2008-03-18 15:43:34 +0000 |
commit | b02bc230af68d05df171a0a099d6c3d94168ab64 (patch) | |
tree | a07721daf3a91733bc3e073bab0697333d426e21 /apps/app_festival.c | |
parent | 760fc3403c7355fa05bc1b7470405239aad7af8e (diff) |
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/trunk@109447 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_festival.c')
-rw-r--r-- | apps/app_festival.c | 24 |
1 files changed, 18 insertions, 6 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); } |