From edabf172f81a3ff7775f85df45454ff7667d5b90 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 19 Nov 2013 19:17:10 +0100 Subject: Check for udp type in tunnel message Since we're currently support celt only, do nothing when retrieving other codecs. --- src/cmumble.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cmumble.c b/src/cmumble.c index cafef90..1d10d97 100644 --- a/src/cmumble.c +++ b/src/cmumble.c @@ -13,12 +13,15 @@ static void recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct cmumble *cm) { int64_t session, sequence; - uint32_t pos = 1, read = 0; + uint32_t pos = 0, read = 0; uint8_t frame_len, terminator; struct cmumble_user *user = NULL; uint8_t *data = tunnel->packet.data; size_t len = tunnel->packet.len; + uint8_t type; + type = data[pos] >> 5; + pos += 1; session = decode_varint(&data[pos], &read, len-pos); pos += read; sequence = decode_varint(&data[pos], &read, len-pos); @@ -26,11 +29,17 @@ recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct cmumble *cm) user = find_user(cm, session); if (user == NULL) { - g_printerr("received audio packet from unknown user, " + g_printerr("Received audio packet from unknown user, " "dropping.\n"); return; } + if (type != udp_voice_celt_alpha) { + g_printerr("Retrieved unimplemented codec %d from: %s\n", + type, user->name); + return; + } + do { frame_len = data[pos] & 0x7F; terminator = data[pos] & 0x80; @@ -39,6 +48,9 @@ recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct cmumble *cm) if (frame_len == 0 || frame_len > len-pos) break; + if (frame_len < 2) + break; + cmumble_audio_push(cm, user, &data[pos], frame_len); pos += frame_len; -- cgit