Fixed wrong buffer length in the 1.8 protocol.
This commit is contained in:
parent
34bcd3dd58
commit
0d34fc9f31
@ -1753,7 +1753,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
m_ReceivedData.ResetRead();
|
m_ReceivedData.ResetRead();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cByteBuffer bb(PacketLen + 1);
|
cByteBuffer bb(PacketLen);
|
||||||
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
||||||
m_ReceivedData.CommitRead();
|
m_ReceivedData.CommitRead();
|
||||||
|
|
||||||
@ -1819,7 +1819,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bb.GetReadableSpace() != 1)
|
if (bb.GetReadableSpace() != 0)
|
||||||
{
|
{
|
||||||
// Read more or less than packet length, report as error
|
// Read more or less than packet length, report as error
|
||||||
LOGWARNING("Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes",
|
LOGWARNING("Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes",
|
||||||
@ -2334,10 +2334,7 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
|
|||||||
{
|
{
|
||||||
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel);
|
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel);
|
||||||
AString Data;
|
AString Data;
|
||||||
if (!a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1))
|
a_ByteBuffer.ReadAll(Data);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_Client->HandlePluginMessage(Channel, Data);
|
m_Client->HandlePluginMessage(Channel, Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2594,10 +2591,7 @@ bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item)
|
|||||||
|
|
||||||
// Read the metadata
|
// Read the metadata
|
||||||
AString Metadata;
|
AString Metadata;
|
||||||
if (a_ByteBuffer.ReadString(Metadata, a_ByteBuffer.GetReadableSpace() - 1))
|
a_ByteBuffer.ReadAll(Metadata);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParseItemMetadata(a_Item, Metadata);
|
ParseItemMetadata(a_Item, Metadata);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user