aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rwxr-xr-xfile.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/file.c b/file.c
index fa3885a98..f0bea5465 100755
--- a/file.c
+++ b/file.c
@@ -279,14 +279,17 @@ static int copy(char *infile, char *outfile)
static char *build_filename(char *filename, char *ext)
{
char *fn;
+ int fnsize = 0;
char tmp[AST_CONFIG_MAX_PATH]="";
- snprintf(tmp,sizeof(tmp)-1,"%s/%s",(char *)ast_config_AST_VAR_DIR,"sounds");
- fn = malloc(strlen(tmp) + strlen(filename) + strlen(ext) + 10);
+
+ snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_VAR_DIR, "sounds");
+ fnsize = strlen(tmp) + strlen(filename) + strlen(ext) + 10;
+ fn = malloc(fnsize);
if (fn) {
if (filename[0] == '/')
- sprintf(fn, "%s.%s", filename, ext);
+ snprintf(fn, fnsize, "%s.%s", filename, ext);
else
- sprintf(fn, "%s/%s.%s", (char *)tmp, filename, ext);
+ snprintf(fn, fnsize, "%s/%s.%s", tmp, filename, ext);
}
return fn;