mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Ignore unknown formats in ast_format_str_reduce() and return an error if no know formats are found.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@231740 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
17
main/file.c
17
main/file.c
@@ -1365,7 +1365,7 @@ char *ast_format_str_reduce(char *fmts)
|
|||||||
char *fmts_str[AST_MAX_FORMATS];
|
char *fmts_str[AST_MAX_FORMATS];
|
||||||
char *stringp, *type;
|
char *stringp, *type;
|
||||||
char *orig = fmts;
|
char *orig = fmts;
|
||||||
int i, j, x, found;
|
int i, j, x, first, found;
|
||||||
int len = strlen(fmts) + 1;
|
int len = strlen(fmts) + 1;
|
||||||
|
|
||||||
if (AST_LIST_LOCK(&formats)) {
|
if (AST_LIST_LOCK(&formats)) {
|
||||||
@@ -1392,11 +1392,19 @@ char *ast_format_str_reduce(char *fmts)
|
|||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&formats);
|
AST_LIST_UNLOCK(&formats);
|
||||||
|
|
||||||
|
first = 1;
|
||||||
for (i = 0; i < x; i++) {
|
for (i = 0; i < x; i++) {
|
||||||
|
/* ignore invalid entries */
|
||||||
|
if (!fmts_ptr[i]) {
|
||||||
|
ast_log(LOG_WARNING, "ignoring unknown format '%s'\n", fmts_str[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* special handling for the first entry */
|
/* special handling for the first entry */
|
||||||
if (i == 0) {
|
if (first) {
|
||||||
fmts += snprintf(fmts, len, "%s", fmts_str[i]);
|
fmts += snprintf(fmts, len, "%s", fmts_str[i]);
|
||||||
len -= (fmts - orig);
|
len -= (fmts - orig);
|
||||||
|
first = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1415,6 +1423,11 @@ char *ast_format_str_reduce(char *fmts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
ast_log(LOG_WARNING, "no known formats found in format list (%s)\n", orig);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return orig;
|
return orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user