mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
CServer::ProcessClientPacket(): Adjust the debug message buffer size
We allocated 512 bytes to dump up to 32 data bytes in a hex form. According to the str_hex() implementation, we need three bytes per the source data byte (a byte is represented as a two-digit hexadecimal number with appended space char) plus the null-termination. We actually could re-use the last space char for the null, but it is not implemented in str_hex(). Keep this logic as-is. The stack-allocated buffer size reduced from 512 to 97 bytes.
This commit is contained in:
parent
92abe8d545
commit
895a0b3451
|
@ -1716,8 +1716,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
{
|
{
|
||||||
if(g_Config.m_Debug)
|
if(g_Config.m_Debug)
|
||||||
{
|
{
|
||||||
char aBuf[512];
|
constexpr int MaxDumpedDataSize = 32;
|
||||||
str_hex(aBuf, sizeof(aBuf), pPacket->m_pData, minimum(pPacket->m_DataSize, 32));
|
char aBuf[MaxDumpedDataSize * 3 + 1];
|
||||||
|
str_hex(aBuf, sizeof(aBuf), pPacket->m_pData, minimum(pPacket->m_DataSize, MaxDumpedDataSize));
|
||||||
|
|
||||||
char aBufMsg[256];
|
char aBufMsg[256];
|
||||||
str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientID=%d msg=%d data_size=%d", ClientID, Msg, pPacket->m_DataSize);
|
str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientID=%d msg=%d data_size=%d", ClientID, Msg, pPacket->m_DataSize);
|
||||||
|
|
Loading…
Reference in a new issue