From 106ce36ca4aaa6909c68edc20974a51812c3cab4 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sun, 3 Sep 2023 15:55:34 -0700 Subject: [PATCH] Sanitize certificate subject name before comparing to deviceId The device ID is sanitized to make it safe for D-Bus, so the device ID stored in the certificate as the subject name also needs to be sanitized before comparison. (cherry picked from commit 0640279ae0b60fcf6001e1e4735610e0ce71ffa2) --- core/backends/lan/lanlinkprovider.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 6f71066ef..c16776126 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -31,6 +31,7 @@ #include #include "daemon.h" +#include "dbushelper.h" #include "kdeconnectconfig.h" #include "landevicelink.h" #include "qtcompat_p.h" @@ -576,6 +577,7 @@ void LanLinkProvider::configureSocket(QSslSocket *socket) void LanLinkProvider::addLink(QSslSocket *socket, const DeviceInfo &deviceInfo) { QString certDeviceId = socket->peerCertificate().subjectDisplayName(); + DBusHelper::filterNonExportableCharacters(certDeviceId); if (deviceInfo.id != certDeviceId) { socket->disconnectFromHost(); qCWarning(KDECONNECT_CORE) << "DeviceID in cert doesn't match deviceID in identity packet. " << deviceInfo.id << " vs " << certDeviceId;