From 7905e38d84a060176e53ffe8d7da8710ea0180fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 Jan 2011 13:29:02 +0100 Subject: Validate arguments to QDBusConnection::connect This fixes a crash caused by user code trying to connect to object paths that aren't valid (if we send this to the bus daemon, we get an error with the AddMatch call). Reviewed-by: Trust Me --- src/dbus/qdbusconnection.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index eb312d2..3fb63eb 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -632,10 +632,26 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const if (!receiver || !slot || !d || !d->connection) return false; - if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) - return false; if (interface.isEmpty() && name.isEmpty()) return false; + if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) { +#ifndef QT_NO_DEBUG + qWarning("QDBusConnection::connect: interface name '%s' is not valid", interface.toLatin1().constData()); +#endif + return false; + } + if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) { +#ifndef QT_NO_DEBUG + qWarning("QDBusConnection::connect: service name '%s' is not valid", service.toLatin1().constData()); +#endif + return false; + } + if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) { +#ifndef QT_NO_DEBUG + qWarning("QDBusConnection::connect: object path '%s' is not valid", path.toLatin1().constData()); +#endif + return false; + } QDBusWriteLocker locker(ConnectAction, d); return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); -- cgit v0.12