#1421 Added limit for maximum send buffer size.

This commit is contained in:
XMRig 2019-12-17 03:18:25 +07:00
parent 17f82280d0
commit a5089638ea
No known key found for this signature in database
GPG key ID: 446A53638BE94409
2 changed files with 11 additions and 8 deletions

View file

@ -159,6 +159,13 @@ int64_t xmrig::Client::send(const rapidjson::Value &obj)
obj.Accept(writer); obj.Accept(writer);
const size_t size = buffer.GetSize(); const size_t size = buffer.GetSize();
if (size > kMaxSendBufferSize) {
LOG_ERR("[%s] send failed: \"max send buffer size exceeded: %zu\"", url(), size);
close();
return -1;
}
if (size > (m_sendBuf.size() - 2)) { if (size > (m_sendBuf.size() - 2)) {
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024); m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
} }

View file

@ -60,14 +60,10 @@ class Client : public BaseClient, public IDnsListener, public ILineListener
public: public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client) XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client)
constexpr static uint64_t kConnectTimeout = 20 * 1000; constexpr static uint64_t kConnectTimeout = 20 * 1000;
constexpr static uint64_t kResponseTimeout = 20 * 1000; constexpr static uint64_t kResponseTimeout = 20 * 1000;
constexpr static size_t kInputBufferSize = 1024 * 16;
# ifdef XMRIG_FEATURE_TLS constexpr static size_t kMaxSendBufferSize = 1024 * 16;
constexpr static size_t kInputBufferSize = 1024 * 16;
# else
constexpr static size_t kInputBufferSize = 1024 * 2;
# endif
Client(int id, const char *agent, IClientListener *listener); Client(int id, const char *agent, IClientListener *listener);
~Client() override; ~Client() override;