diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-01-14 12:29:02 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-01-21 22:08:32 (GMT) |
commit | 7905e38d84a060176e53ffe8d7da8710ea0180fe (patch) | |
tree | 3aaf55703b129269b740ab6a5a957b654c436133 | |
parent | 383a7129a1dffc54d8ebbc2c6497792b72fea6f1 (diff) | |
download | Qt-7905e38d84a060176e53ffe8d7da8710ea0180fe.zip Qt-7905e38d84a060176e53ffe8d7da8710ea0180fe.tar.gz Qt-7905e38d84a060176e53ffe8d7da8710ea0180fe.tar.bz2 |
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
-rw-r--r-- | src/dbus/qdbusconnection.cpp | 20 |
1 files 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); |