From a58fd5ae15e6333862aff43223315244cd171d75 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 10 Nov 2009 23:50:58 +0000 Subject: [PATCH] prevent obscure divide by zero code path git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15413 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/applications/mod_voicemail/mod_voicemail.c | 2 +- src/switch_core_file.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index b36b3fb864..60f814f95f 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1158,7 +1158,7 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t got_file = 1; } - if (limit && (*message_len = fh.samples_out / fh.samplerate) < profile->min_record_len) { + if (limit && (*message_len = fh.samples_out / fh.samplerate ? fh.samplerate : 8000) < profile->min_record_len) { if (unlink(file_path) != 0) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path); } diff --git a/src/switch_core_file.c b/src/switch_core_file.c index 66f2020181..bc8f64b7f1 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -52,6 +52,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n"); return SWITCH_STATUS_FALSE; } + + if (!fh->samplerate) { + if (!(fh->samplerate = rate)) { + fh->samplerate = 8000; + } + } if (zstr(file_path)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n"); @@ -135,12 +141,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, fh->handler = switch_core_strdup(fh->memory_pool, rhs); } - if (!fh->samplerate) { - if (!(fh->samplerate = rate)) { - fh->samplerate = 8000; - } - } - if (channels) { fh->channels = channels; } else {