Add safety check for codec implementations with bytes_per_frames being larger than the recommended buffer size (Klocwork #1039)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8514 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Stefan Knoblich 2008-05-21 22:26:30 +00:00
parent 0bdd7007d0
commit 088b842ced
2 changed files with 10 additions and 4 deletions

View File

@ -487,6 +487,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
if (switch_test_flag(read_frame, SFF_CNG)) { if (switch_test_flag(read_frame, SFF_CNG)) {
sendlen = read_codec->implementation->bytes_per_frame; sendlen = read_codec->implementation->bytes_per_frame;
switch_assert(sendlen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
memset(decoded, 255, sendlen); memset(decoded, 255, sendlen);
sendbuf = decoded; sendbuf = decoded;
tstatus = SWITCH_STATUS_SUCCESS; tstatus = SWITCH_STATUS_SUCCESS;

View File

@ -154,13 +154,18 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
for (impl = ptr->implementations; impl; impl = impl->next) { for (impl = ptr->implementations; impl; impl = impl->next) {
if (!impl->iananame) { if (!impl->iananame) {
load_interface = 0; load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"Failed to load codec interface %s from %s due to no iana name in an implementation.\n", ptr->interface_name, key);
break;
}
if (impl->bytes_per_frame > SWITCH_RECOMMENDED_BUFFER_SIZE) {
load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"Failed to load codec interface %s from %s due to bytes per frame exceeding buffer size.\n", ptr->interface_name, key);
break; break;
} }
} }
if (!load_interface) { if (load_interface) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"Failed to load codec interface %s from %s due to no iana name in an implementation.\n", ptr->interface_name, key);
} else {
for (impl = ptr->implementations; impl; impl = impl->next) { for (impl = ptr->implementations; impl; impl = impl->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Adding Codec '%s' (%s) %dhz %dms\n", "Adding Codec '%s' (%s) %dhz %dms\n",