From 504b88eddd53006a9b1d2a6f7a2ce8abad5e65c8 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 24 Nov 2020 15:58:50 +0100 Subject: [PATCH] Increase the maximum allowed message size in JSONRPC Turns out 10KB can be exceeded with scripting --- libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp | 4 ++-- tests/auto/jsonrpc/testjsonrpc.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp b/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp index 33671c20..20fe2536 100644 --- a/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp +++ b/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp @@ -621,8 +621,8 @@ void JsonRPCServerImplementation::processData(const QUuid &clientId, const QByte } m_clientBuffers[clientId] = buffer; - if (buffer.size() > 1024 * 10) { - qCWarning(dcJsonRpc()) << "Client buffer larger than 10KB and no valid data. Dropping client connection."; + if (buffer.size() > 1024 * 1024) { + qCWarning(dcJsonRpc()) << "Client buffer larger than 1MB and no valid data. Dropping client connection."; interface->terminateClientConnection(clientId); } } diff --git a/tests/auto/jsonrpc/testjsonrpc.cpp b/tests/auto/jsonrpc/testjsonrpc.cpp index 7fddb182..a8145e2a 100644 --- a/tests/auto/jsonrpc/testjsonrpc.cpp +++ b/tests/auto/jsonrpc/testjsonrpc.cpp @@ -1379,7 +1379,7 @@ void TestJSONRPC::testGarbageData() QSignalSpy spy(m_mockTcpServer, &MockTcpServer::connectionTerminated); QByteArray data; - for (int i = 0; i < 1024; i++) { + for (int i = 0; i < 1024 * 1024; i++) { data.append("a"); } for (int i = 0; i < 11 && spy.count() == 0; i ++) {