mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@238630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
11
main/file.c
11
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user