NetPlay: reject oversized input buffer messages

A NetPlay host could send an arbitrary buffer size to a client. The
client then tried to allocate input states until it reached that value.

Limit buffer sizes to the existing user-interface maximum. Invalid peer
values are ignored.
This commit is contained in:
Acts1631 authored and OatmealDome committed 2026-10-07 19:56:01 -04:00
1 parent b5ded04314
commit a5c88ec00e
3 files changed
+10 -2

No files matched your search

+7 -2
View File
@@ -754,8 +754,13 @@ void NetPlayClient::OnPadBuffer(sf::Packet& packet)
u32 size = 0;
packet >> size;
m_target_buffer_size = size;
m_dialog->OnPadBufferChanged(size);
if (size > MAX_TARGET_PAD_BUFFER_SIZE)
{
WARN_LOG_FMT(NETPLAY, "Ignoring invalid pad buffer size {}.", size);
return;
}
AdjustPadBufferSize(size);
}
void NetPlayClient::OnHostInputAuthority(sf::Packet& packet)
+1
View File
@@ -244,6 +244,7 @@ enum class SyncCodeID : u8
};
constexpr u32 MAX_NAME_LENGTH = 30;
constexpr u32 MAX_TARGET_PAD_BUFFER_SIZE = 99;
constexpr size_t CHUNKED_DATA_UNIT_SIZE = 16384;
constexpr u32 MAX_ENET_MTU = 1392; // see https://github.com/lsalzman/enet/issues/132
@@ -33,6 +33,7 @@
#include "Common/Logging/Log.h"
#include "Common/TraversalClient.h"
#include "Core/NetPlayCommon.h"
#include "Core/NetPlayProto.h"
#include "Core/Boot/Boot.h"
#include "Core/Config/GraphicsSettings.h"
@@ -130,6 +131,7 @@ void NetPlayDialog::CreateMainLayout()
m_game_button = new QPushButton;
m_start_button = new QPushButton(tr("Start"));
m_buffer_size_box = new QSpinBox;
m_buffer_size_box->setMaximum(NetPlay::MAX_TARGET_PAD_BUFFER_SIZE);
m_buffer_label = new QLabel(tr("Buffer:"));
m_quit_button = new QPushButton(tr("Quit"));
m_splitter = new QSplitter(Qt::Horizontal);