From 7676468780f61f238ac5c02eb2e13a81ecbf656f Mon Sep 17 00:00:00 2001 From: Intel Date: Sun, 11 May 2014 14:00:28 -0400 Subject: [PATCH] Limit packet size --- src/server/poolserver/Stratum/Client.cpp | 4 ++++ src/server/poolserver/Stratum/Server.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/server/poolserver/Stratum/Client.cpp b/src/server/poolserver/Stratum/Client.cpp index 4942d59..0ad8f23 100644 --- a/src/server/poolserver/Stratum/Client.cpp +++ b/src/server/poolserver/Stratum/Client.cpp @@ -388,6 +388,10 @@ namespace Stratum } else _recvMessage += c; } + + // Check if message doesn't exceed maximum packet size + if (_recvMessage.size() > MAX_PACKET) + Disconnect(); StartRead(); } else { diff --git a/src/server/poolserver/Stratum/Server.h b/src/server/poolserver/Stratum/Server.h index a77246a..208b10d 100644 --- a/src/server/poolserver/Stratum/Server.h +++ b/src/server/poolserver/Stratum/Server.h @@ -18,6 +18,8 @@ #include #include +#define MAX_PACKET 4096 + using namespace boost; using namespace boost::asio::ip;