From 23db49db635e95f1c492118607078991a5fc5a18 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 10 Oct 2020 13:02:24 +0200 Subject: [PATCH] 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) --- src/engine/client/serverbrowser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index ce9690263..793d5bce7 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -290,7 +290,7 @@ void CServerBrowser::Filter() { // check for friend 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_aClan);