From 9a3304c65d9630117b1a9dac7c3839976d4a3c88 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Mon, 10 Jan 2005 04:18:18 +0000 Subject: Fix voicemail symlinks (bug #3024) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4743 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- file.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 57b2b7adb..4213f5e31 100755 --- a/file.c +++ b/file.c @@ -282,19 +282,23 @@ static char *build_filename(const char *filename, const char *ext) { char *fn; int fnsize = 0; - char tmp[AST_CONFIG_MAX_PATH]=""; - 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] == '/') + if (filename[0] == '/') { + fnsize = strlen(filename) + strlen(ext) + 2; + fn = malloc(fnsize); + if (fn) snprintf(fn, fnsize, "%s.%s", filename, ext); - else + } else { + char tmp[AST_CONFIG_MAX_PATH] = ""; + + snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_VAR_DIR, "sounds"); + fnsize = strlen(tmp) + strlen(filename) + strlen(ext) + 3; + fn = malloc(fnsize); + if (fn) snprintf(fn, fnsize, "%s/%s.%s", tmp, filename, ext); } + return fn; - } static int exts_compare(const char *exts, const char *type) -- cgit v1.2.3