aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-01 15:34:57 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-01 15:34:57 +0000
commitc242ae2b6564ccd5182714f4103459c69fdbe648 (patch)
treecf337aa3ca5dbb3f9f8945bdd4e6ea2a3b2ab98d /main
parentb9e5510d228a6a258103294c00b4b908498a91dc (diff)
Ignore unknown formats in ast_format_str_reduce() and return an error if no know formats are found.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@231740 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/file.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/main/file.c b/main/file.c
index 6631112c4..164560312 100644
--- a/main/file.c
+++ b/main/file.c
@@ -1365,7 +1365,7 @@ char *ast_format_str_reduce(char *fmts)
char *fmts_str[AST_MAX_FORMATS];
char *stringp, *type;
char *orig = fmts;
- int i, j, x, found;
+ int i, j, x, first, found;
int len = strlen(fmts) + 1;
if (AST_LIST_LOCK(&formats)) {
@@ -1392,11 +1392,19 @@ char *ast_format_str_reduce(char *fmts)
}
AST_LIST_UNLOCK(&formats);
+ first = 1;
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 */
- if (i == 0) {
+ if (first) {
fmts += snprintf(fmts, len, "%s", fmts_str[i]);
len -= (fmts - orig);
+ first = 0;
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;
}