From c77f45f22143414526dd9a19597421e48a98b61d Mon Sep 17 00:00:00 2001 From: johan Date: Sat, 9 Nov 2013 10:33:16 +0100 Subject: [PATCH] Protect Boblight server against clients sending too much data Former-commit-id: f3a575f71425da25fbaad68c48dcec746a50def2 --- libsrc/boblightserver/BoblightClientConnection.cpp | 8 ++++++++ src/hyperiond/hyperiond.cpp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/libsrc/boblightserver/BoblightClientConnection.cpp b/libsrc/boblightserver/BoblightClientConnection.cpp index 5c8ad796..636cedda 100644 --- a/libsrc/boblightserver/BoblightClientConnection.cpp +++ b/libsrc/boblightserver/BoblightClientConnection.cpp @@ -67,6 +67,13 @@ void BoblightClientConnection::readData() // handle message handleMessage(message); + // drop messages if the buffer is too full + if (_receiveBuffer.size() > 100*1024) + { + std::cout << "Boblight server drops messages" << std::endl; + _receiveBuffer.clear(); + } + // try too look up '\n' again bytes = _receiveBuffer.indexOf('\n') + 1; } @@ -183,6 +190,7 @@ void BoblightClientConnection::handleMessage(const QString & message) { _hyperion->setColors(_priority, _ledColors, -1); } + return; } } diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index a119cffc..13987a72 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -32,6 +32,9 @@ void signal_handler(const int signum) { QCoreApplication::quit(); + + // reset signal handler to default (in case this handler is not capable of stopping) + signal(signum, SIG_DFL); } Json::Value loadConfig(const std::string & configFile)