From 6119cb370fe410c1ef25f2d2c28c8a0edf6fac22 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 27 Jun 2019 20:29:02 +0800 Subject: [PATCH 1/2] Drop suspiciously large data This is to avoid exhausting system memory. --- src/app/qtsingleapplication/qtlocalpeer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/qtsingleapplication/qtlocalpeer.cpp b/src/app/qtsingleapplication/qtlocalpeer.cpp index f3c4546b6..cb4c57492 100644 --- a/src/app/qtsingleapplication/qtlocalpeer.cpp +++ b/src/app/qtsingleapplication/qtlocalpeer.cpp @@ -191,6 +191,12 @@ void QtLocalPeer::receiveConnection() QByteArray uMsg; quint32 remaining; ds >> remaining; + if (remaining > 65535) { + // drop suspiciously large data + delete socket; + return; + } + uMsg.resize(remaining); int got = 0; char* uMsgBuf = uMsg.data(); From 46ee193cd8374576abf78b68caba395794e0a9da Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 27 Jun 2019 20:33:05 +0800 Subject: [PATCH 2/2] Restrict QLocalServer access The default is world access which means even even unprivileged local accounts can connect to it too. --- src/app/qtsingleapplication/qtlocalpeer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/qtsingleapplication/qtlocalpeer.cpp b/src/app/qtsingleapplication/qtlocalpeer.cpp index cb4c57492..d8a1bce31 100644 --- a/src/app/qtsingleapplication/qtlocalpeer.cpp +++ b/src/app/qtsingleapplication/qtlocalpeer.cpp @@ -101,6 +101,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) #endif server = new QLocalServer(this); + server->setSocketOptions(QLocalServer::UserAccessOption); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName + QLatin1String("-lockfile");