Skip to content

Commit 0262550

Browse files
StephenCWillsAJenbo
authored andcommitted
Validate echo requests and replies
1 parent 97a4c64 commit 0262550

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Source/dvlnet/base.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ tl::expected<void, PacketError> base::HandleDisconnect(packet &pkt)
155155

156156
tl::expected<void, PacketError> base::HandleEchoRequest(packet &pkt)
157157
{
158+
// If we have already left the game,
159+
// there is no need to respond to echoes
160+
if (plr_self == PLR_BROADCAST) return {};
161+
158162
return pkt.Time()
159163
.and_then([&](cookie_t &&pktTime) {
160164
return pktfty->make_packet<PT_ECHO_REPLY>(plr_self, pkt.Source(), pktTime);
@@ -168,6 +172,7 @@ tl::expected<void, PacketError> base::HandleEchoReply(packet &pkt)
168172
{
169173
const uint32_t now = SDL_GetTicks();
170174
plr_t src = pkt.Source();
175+
if (src >= MAX_PLRS) return {};
171176
return pkt.Time().transform([&](cookie_t &&pktTime) {
172177
PlayerState &playerState = playerStateTable_[src];
173178
playerState.roundTripLatency = now - pktTime;

0 commit comments

Comments
 (0)