Skip to content

Commit

Permalink
Audio, AudioOutput: guard against invalid packet types in AudioOutput…
Browse files Browse the repository at this point in the history
…::addFrameToBuffer().

For packets we receive from Murmur, we check that they're a valid voice
packet on receipt.

However, some packets are not received by Murmur, but generated by the
client itself: packets for RecordUser, and local loopback packets.

If we mess up their type due to a bug, we'd previously allow them into the
AudioOutput system. This commit discards them before they get there.
  • Loading branch information
mkrautz committed Feb 25, 2017
1 parent aa2683f commit f4dfc4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ class MessageHandler {
#undef MUMBLE_MH_MSG
};

/// UDPMessageTypeIsValidVoicePacket checks whether the given
/// UDPMessageType is a valid voice packet.
inline bool UDPMessageTypeIsValidVoicePacket(MessageHandler::UDPMessageType umt) {
switch (umt) {
case MessageHandler::UDPVoiceCELTAlpha:
case MessageHandler::UDPVoiceSpeex:
case MessageHandler::UDPVoiceCELTBeta:
case MessageHandler::UDPVoiceOpus:
return true;
case MessageHandler::UDPPing:
return false;
}
return false;
}

inline QString u8(const ::std::string &str) {
return QString::fromUtf8(str.data(), static_cast<int>(str.length()));
}
Expand Down
5 changes: 5 additions & 0 deletions src/mumble/AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ void AudioOutput::addFrameToBuffer(ClientUser *user, const QByteArray &qbaPacket
qrwlOutputs.lockForRead();
AudioOutputSpeech *aop = qobject_cast<AudioOutputSpeech *>(qmOutputs.value(user));

if (!UDPMessageTypeIsValidVoicePacket(type)) {
qWarning("AudioOutput: ignored frame with invalid message type 0x%x in addFrameToBuffer().", static_cast<unsigned char>(type));
return;
}

if (! aop || (aop->umtType != type)) {
qrwlOutputs.unlock();

Expand Down

0 comments on commit f4dfc4a

Please sign in to comment.