diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-08 19:32:11 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-08 19:32:11 +0000 |
commit | 2400d53feb0cb87af1e416ab4940c3c9c8ad2a4c (patch) | |
tree | e8c8ffddeff2bff508f742817ec151e754088ac4 | |
parent | a896f4d64aa1572c102c98d50ee65f071fd26f3d (diff) |
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/trunk@238630 f38db490-d61c-443f-a65b-d21fe96a405b
-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 075062ba3..a5f85ffd5 100644 --- a/main/file.c +++ b/main/file.c @@ -1356,6 +1356,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"); @@ -1391,8 +1392,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; } @@ -1407,8 +1409,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; } } |