Protocols: Ignore garbage data at the end of PluginMessage packets.
Fixes #1692.
This commit is contained in:
parent
35a3a1b9f4
commit
06c2669cf6
@ -2242,6 +2242,7 @@ void cProtocol172::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
|
|||||||
{
|
{
|
||||||
if (a_Channel == "MC|AdvCdm")
|
if (a_Channel == "MC|AdvCdm")
|
||||||
{
|
{
|
||||||
|
size_t BeginningSpace = a_ByteBuffer.GetReadableSpace();
|
||||||
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Mode);
|
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Mode);
|
||||||
switch (Mode)
|
switch (Mode)
|
||||||
{
|
{
|
||||||
@ -2265,6 +2266,16 @@ void cProtocol172::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} // switch (Mode)
|
} // switch (Mode)
|
||||||
|
|
||||||
|
// Read the remainder of the packet (Vanilla sometimes sends bogus data at the end of the packet; #1692):
|
||||||
|
size_t BytesRead = BeginningSpace - a_ByteBuffer.GetReadableSpace();
|
||||||
|
if (BytesRead < static_cast<size_t>(a_PayloadLength))
|
||||||
|
{
|
||||||
|
LOGD("Protocol 1.7: Skipping garbage data at the end of a vanilla MC|AdvCdm packet, %u bytes",
|
||||||
|
a_PayloadLength - BytesRead
|
||||||
|
);
|
||||||
|
a_ByteBuffer.SkipRead(a_PayloadLength - BytesRead);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (a_Channel == "MC|Brand")
|
else if (a_Channel == "MC|Brand")
|
||||||
|
@ -2331,6 +2331,16 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
|
|||||||
if (Channel.substr(0, 3) == "MC|")
|
if (Channel.substr(0, 3) == "MC|")
|
||||||
{
|
{
|
||||||
HandleVanillaPluginMessage(a_ByteBuffer, Channel);
|
HandleVanillaPluginMessage(a_ByteBuffer, Channel);
|
||||||
|
|
||||||
|
// Skip any unread data (vanilla sometimes sends garbage at the end of a packet; #1692):
|
||||||
|
if (a_ByteBuffer.GetReadableSpace() > 1)
|
||||||
|
{
|
||||||
|
LOGD("Protocol 1.8: Skipping garbage data at the end of a vanilla PluginMessage packet, %u bytes",
|
||||||
|
a_ByteBuffer.GetReadableSpace() - 1
|
||||||
|
);
|
||||||
|
a_ByteBuffer.SkipRead(a_ByteBuffer.GetReadableSpace() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user