#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);
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)) {
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
}

View file

@ -62,12 +62,8 @@ public:
constexpr static uint64_t kConnectTimeout = 20 * 1000;
constexpr static uint64_t kResponseTimeout = 20 * 1000;
# ifdef XMRIG_FEATURE_TLS
constexpr static size_t kInputBufferSize = 1024 * 16;
# else
constexpr static size_t kInputBufferSize = 1024 * 2;
# endif
constexpr static size_t kMaxSendBufferSize = 1024 * 16;
Client(int id, const char *agent, IClientListener *listener);
~Client() override;