diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-08 19:34:03 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-08 19:34:03 +0000 |
commit | d7c5778dc0f65ea9b0e158fa726be39e7a5bafff (patch) | |
tree | f70032bf1f07bddaa0be1c0fc08721169e0e49ad /main | |
parent | 4f472701354cbfd2adbce523bc5dac9c2587c8ac (diff) |
Merged revisions 238630 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r238630 | mnicholson | 2010-01-08 13:32:11 -0600 (Fri, 08 Jan 2010) | 12 lines
Merged revisions 238629 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r238629 | mnicholson | 2010-01-08 13:20:44 -0600 (Fri, 08 Jan 2010) | 5 lines
Properly calculate the remaining space in the output string when reducing format strings.
(closes issue #16560)
Reported by: goldwein
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@238633 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/file.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/main/file.c b/main/file.c index 2bca64871..6dcc3b452 100644 --- a/main/file.c +++ b/main/file.c @@ -1344,6 +1344,7 @@ char *ast_format_str_reduce(char *fmts) char *orig = fmts; int i, j, x, first, found = 0; int len = strlen(fmts) + 1; + int res; if (AST_RWLIST_RDLOCK(&formats)) { ast_log(LOG_WARNING, "Unable to lock format list\n"); @@ -1379,8 +1380,9 @@ char *ast_format_str_reduce(char *fmts) /* special handling for the first entry */ if (first) { - fmts += snprintf(fmts, len, "%s", fmts_str[i]); - len -= (fmts - orig); + res = snprintf(fmts, len, "%s", fmts_str[i]); + fmts += res; + len -= res; first = 0; continue; } @@ -1395,8 +1397,9 @@ char *ast_format_str_reduce(char *fmts) } if (!found) { - fmts += snprintf(fmts, len, "|%s", fmts_str[i]); - len -= (fmts - orig); + res = snprintf(fmts, len, "|%s", fmts_str[i]); + fmts += res; + len -= res; } } |