diff options
author | Benjamin Jemlich <pcgod@users.sourceforge.net> | 2012-07-16 21:29:53 +0400 |
---|---|---|
committer | Benjamin Jemlich <pcgod@users.sourceforge.net> | 2012-07-16 21:29:53 +0400 |
commit | 994e130a9d49621c1516b44fcb8fbffd25e59078 (patch) | |
tree | 7b47717c5dc156a91cc22f22a1870158753ad333 | |
parent | ab940f1948aa5d5b4efc723e48c3ff7827c7c947 (diff) |
Murmur: Fix message type detection in Server::processMsg and add a few more comments
Bug found by Rok Kek <rok.kek@gmail.com> which could affect Opus packets.
-rw-r--r-- | src/murmur/Server.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 34a029f99..b9ffdc4d9 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -897,7 +897,6 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { char buffer[UDP_PACKET_SIZE]; PacketDataStream pdi(data + 1, len - 1); PacketDataStream pds(buffer+1, UDP_PACKET_SIZE-1); - MessageHandler::UDPMessageType msgType = static_cast<MessageHandler::UDPMessageType>((buffer[0] >> 5) & 0x7); unsigned int type = data[0] & 0xe0; unsigned int target = data[0] & 0x1f; unsigned int poslen; @@ -905,14 +904,17 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { // IP + UDP + Crypt + Data int packetsize = 20 + 8 + 4 + len; + // Check the voice data rate limit. if (! bw->addFrame(packetsize, iMaxBandwidth/8)) { // Suppress packet. return; } + // Read the sequence number. pdi >> counter; - if (msgType != MessageHandler::UDPVoiceOpus) { + // Skip to the end of the voice data. + if ((type >> 5) != MessageHandler::UDPVoiceOpus) { do { counter = pdi.next8(); pdi.skip(counter & 0x7f); @@ -923,9 +925,12 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { pdi.skip(size & 0x1fff); } + // Save location of the positional audio data. poslen = pdi.left(); + // Append session id to the new output stream. pds << u->uiSession; + // Copy all voice and positional audio data to the output stream. pds.append(data + 1, len - 1); len = pds.size() + 1; |