[svn-commits] russell: branch 1.4 r89037 - /branches/1.4/res/res_musiconhold.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Nov 6 12:20:08 CST 2007
Author: russell
Date: Tue Nov 6 12:20:07 2007
New Revision: 89037
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89037
Log:
If someone were to delete the files used by an existing MOH class, and then
issue a reload, further use of that class could result in a crash due to
dividing by zero. This set of changes fixes up some places to prevent this
from happening.
(closes issue #10948)
Reported by: jcomellas
Patches:
res_musiconhold_division_by_zero.patch uploaded by jcomellas (license 282)
Additional changes added by me.
Modified:
branches/1.4/res/res_musiconhold.c
Modified: branches/1.4/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_musiconhold.c?view=diff&rev=89037&r1=89036&r2=89037
==============================================================================
--- branches/1.4/res/res_musiconhold.c (original)
+++ branches/1.4/res/res_musiconhold.c Tue Nov 6 12:20:07 2007
@@ -231,6 +231,11 @@
chan->stream = NULL;
}
+ if (!state->class->total_files) {
+ ast_log(LOG_WARNING, "No files available for class '%s'\n", state->class->name);
+ return -1;
+ }
+
/* If a specific file has been saved, use it */
if (state->save_pos >= 0) {
state->pos = state->save_pos;
@@ -321,7 +326,7 @@
/* initialize */
memset(state, 0, sizeof(*state));
state->class = class;
- if (ast_test_flag(state->class, MOH_RANDOMIZE))
+ if (ast_test_flag(state->class, MOH_RANDOMIZE) && class->total_files)
state->pos = ast_random() % class->total_files;
}
@@ -1259,8 +1264,15 @@
AST_LIST_REMOVE_CURRENT(&mohclasses, list);
if (!moh->inuse)
ast_moh_destroy_one(moh);
- } else if (moh->total_files)
- moh_scan_files(moh);
+ } else if (moh->total_files) {
+ if (moh_scan_files(moh)) {
+ ast_log(LOG_WARNING, "No files found for class '%s'\n", moh->name);
+ moh->delete = 1;
+ AST_LIST_REMOVE_CURRENT(&mohclasses, list);
+ if (!moh->inuse)
+ ast_moh_destroy_one(moh);
+ }
+ }
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&mohclasses);
More information about the svn-commits
mailing list