Server browser: Don't access friends out of bounds

src/engine/client/serverbrowser.cpp:295:88: runtime error: index 64 out of bounds for type 'CServerInfo::CClient [64]'
    #0 0x565020e035bd in CServerBrowser::Filter() /media/ddnet/src/engine/client/serverbrowser.cpp:295:128
    #1 0x565020e053b3 in CServerBrowser::Sort() /media/ddnet/src/engine/client/serverbrowser.cpp:352:2
    #2 0x565020e0c364 in CServerBrowser::Set(NETADDR const&, int, int, CServerInfo const*) /media/ddnet/src/engine/client/serverbrowser.cpp:620:2
    #3 0x565020cf9854 in CClient::ProcessServerInfo(int, NETADDR*, void const*, int) /media/ddnet/src/engine/client/client.cpp:1524:20
    #4 0x565020cf8132 in CClient::ProcessConnlessPacket(CNetChunk*) /media/ddnet/src/engine/client/client.cpp:1357:4
    #5 0x565020d11656 in CClient::PumpNetwork() /media/ddnet/src/engine/client/client.cpp:2575:5
    #6 0x565020d1ba21 in CClient::Update() /media/ddnet/src/engine/client/client.cpp:2856:2
    #7 0x565020d26efe in CClient::Run() /media/ddnet/src/engine/client/client.cpp:3237:4
    #8 0x565020d48b2e in main /media/ddnet/src/engine/client/client.cpp:4341:11
    #9 0x7f4311524151 in __libc_start_main (/usr/lib/libc.so.6+0x28151)
    #10 0x565020a95e0d in _start (/media/ddnet/DDNet+0x705e0d)
This commit is contained in:
def 2020-10-10 13:02:24 +02:00
parent 60f4e078b7
commit 23db49db63

View file

@ -290,7 +290,7 @@ void CServerBrowser::Filter()
{ {
// check for friend // check for friend
m_ppServerlist[i]->m_Info.m_FriendState = IFriends::FRIEND_NO; m_ppServerlist[i]->m_Info.m_FriendState = IFriends::FRIEND_NO;
for(p = 0; p < m_ppServerlist[i]->m_Info.m_NumClients; p++) for(p = 0; p < minimum(m_ppServerlist[i]->m_Info.m_NumClients, (int)MAX_CLIENTS); p++)
{ {
m_ppServerlist[i]->m_Info.m_aClients[p].m_FriendState = m_pFriends->GetFriendState(m_ppServerlist[i]->m_Info.m_aClients[p].m_aName, m_ppServerlist[i]->m_Info.m_aClients[p].m_FriendState = m_pFriends->GetFriendState(m_ppServerlist[i]->m_Info.m_aClients[p].m_aName,
m_ppServerlist[i]->m_Info.m_aClients[p].m_aClan); m_ppServerlist[i]->m_Info.m_aClients[p].m_aClan);