]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add sanity check to project size of decoded codec data
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 25 Mar 2010 21:36:11 +0000 (21:36 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 25 Mar 2010 21:36:11 +0000 (21:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17108 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_codec.c

index 2ac5ea6b155261b5b44135b92de6c1638b8785c7..9a78c5a5f3bc57d175f1aadcb9c71230b188adac 100644 (file)
@@ -621,6 +621,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
                return SWITCH_STATUS_NOT_INITALIZED;
        }
 
+       if (codec->implementation->encoded_bytes_per_packet) {
+               uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet;
+
+               if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n");
+                       return SWITCH_STATUS_GENERR;
+               }
+       }
+       
        if (codec->mutex)
                switch_mutex_lock(codec->mutex);
        status = codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate,