summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-19 19:17:10 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-22 08:27:18 +0100
commitedabf172f81a3ff7775f85df45454ff7667d5b90 (patch)
tree38ebd1b623b12a01402eebc3f949729f1ca6b6f4
parent19250ba1e16857c70cbbfe15b9e939b95e009896 (diff)
downloadcmumble-edabf172f81a3ff7775f85df45454ff7667d5b90.tar.gz
cmumble-edabf172f81a3ff7775f85df45454ff7667d5b90.tar.bz2
cmumble-edabf172f81a3ff7775f85df45454ff7667d5b90.zip
Check for udp type in tunnel message
Since we're currently support celt only, do nothing when retrieving other codecs.
-rw-r--r--src/cmumble.c16
1 files 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;