Fix inline comments for data buffer size violation and remove uneccesary critical debugs

This commit is contained in:
Simon Stürz 2019-06-24 08:18:52 +02:00 committed by Simon Stürz
parent b91f89fea2
commit e902f46fd4
5 changed files with 7 additions and 12 deletions

View File

@ -46,7 +46,7 @@ AuthenticationReply::AuthenticationReply(ProxyClient *proxyClient, QObject *pare
AuthenticationReply::~AuthenticationReply() AuthenticationReply::~AuthenticationReply()
{ {
qCCritical(dcAuthentication()) << "Destroy authentication reply";
} }
QPointer<ProxyClient> AuthenticationReply::proxyClient() const QPointer<ProxyClient> AuthenticationReply::proxyClient() const

View File

@ -334,9 +334,9 @@ void JsonRpcServer::processData(ProxyClient *proxyClient, const QByteArray &data
QList<QByteArray> packages = proxyClient->processData(data); QList<QByteArray> packages = proxyClient->processData(data);
// Make sure the buffer size is in range // Make sure the buffer size is in range
if (proxyClient->bufferSizeViolation()) { if (proxyClient->bufferSize() > 1024 * 10) {
qCWarning(dcJsonRpc()) << "Data buffer size violation from" << proxyClient; qCWarning(dcJsonRpc()) << "Data buffer size violation from" << proxyClient;
proxyClient->killConnection("Data buffer size violation. Data >= 10 kB"); proxyClient->killConnection("Data buffer size violation.");
return; return;
} }

View File

@ -234,17 +234,12 @@ QList<QByteArray> ProxyClient::processData(const QByteArray &data)
m_dataBuffers.clear(); m_dataBuffers.clear();
} }
if (m_dataBuffers.size() > 1024 * 10) {
qCWarning(dcJsonRpc()) << "Client buffer larger than 10KB and no valid data. This is a buffer size violation.";
m_bufferSizeViolation = true;
}
return packages; return packages;
} }
bool ProxyClient::bufferSizeViolation() const int ProxyClient::bufferSize() const
{ {
return m_bufferSizeViolation; return m_dataBuffers.size();
} }
QDebug operator<<(QDebug debug, ProxyClient *proxyClient) QDebug operator<<(QDebug debug, ProxyClient *proxyClient)

View File

@ -98,7 +98,7 @@ public:
// Json server methods // Json server methods
int generateMessageId(); int generateMessageId();
QList<QByteArray> processData(const QByteArray &data); QList<QByteArray> processData(const QByteArray &data);
bool bufferSizeViolation() const; int bufferSize() const;
private: private:
TransportInterface *m_interface = nullptr; TransportInterface *m_interface = nullptr;

View File

@ -85,6 +85,6 @@ MockAuthenticationReply::MockAuthenticationReply(int timeout, Authenticator::Aut
MockAuthenticationReply::~MockAuthenticationReply() MockAuthenticationReply::~MockAuthenticationReply()
{ {
qCCritical(dcAuthentication()) << "Destroy mock authentication reply";
} }