[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/qt-dbus
From:       Thiago Macieira <thiago () kde ! org>
Date:       2006-06-05 15:53:34
Message-ID: 1149522814.795604.12254.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 548455 by thiago:

Add some extra checking on the input data. This affects the dbusidl2cpp tool as well

 M  +55 -14    src/qdbusxmlparser.cpp  
 M  +15 -1     tools/dbus.cpp  


--- trunk/kdesupport/qt-dbus/src/qdbusxmlparser.cpp #548454:548455
@@ -47,8 +47,11 @@
         QString name = ann.attribute(QLatin1String("name")),
                value = ann.attribute(QLatin1String("value"));
 
-        if (name.isEmpty())
+        if (!QDBusUtil::isValidInterfaceName(name)) {
+            qWarning("Invalid D-BUS annotation '%s' found while parsing \
introspection", +                     qPrintable(name));
             continue;
+        }
 
         retval.insert(name, value);
     }
@@ -74,8 +77,11 @@
             if (arg.hasAttribute(QLatin1String("name")))
                 argData.name = arg.attribute(QLatin1String("name")); // can be empty
             argData.type = arg.attribute(QLatin1String("type"));
-            if (!QDBusUtil::isValidSingleSignature(argData.type))
+            if (!QDBusUtil::isValidSingleSignature(argData.type)) {
+                qWarning("Invalid D-BUS type signature '%s' found while parsing \
introspection", +                         qPrintable(argData.type));
                 continue;
+            }
 
             retval << argData;
         }
@@ -111,8 +117,13 @@
     {
         QDomElement iface = interfaceList.item(i).toElement();
         QString ifaceName = iface.attribute(QLatin1String("name"));
-        if (iface.isNull() || ifaceName.isEmpty())
+        if (iface.isNull())
             continue;           // for whatever reason
+        if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
+            qWarning("Invalid D-BUS interface name '%s' found while parsing \
introspection", +                     qPrintable(ifaceName));
+            continue;
+        }
 
         QDBusIntrospection::Interface *ifaceData = new \
QDBusIntrospection::Interface;  ifaceData->name = ifaceName;
@@ -131,8 +142,13 @@
         {
             QDomElement method = list.item(j).toElement();
             QString methodName = method.attribute(QLatin1String("name"));
-            if (method.isNull() || methodName.isEmpty())
+            if (method.isNull())
                 continue;
+            if (!QDBusUtil::isValidMemberName(methodName)) {
+                qWarning("Invalid D-BUS member name '%s' found in interface '%s' \
while parsing introspection", +                         qPrintable(methodName), \
qPrintable(ifaceName)); +                continue;
+            }
 
             QDBusIntrospection::Method methodData;
             methodData.name = methodName;
@@ -152,8 +168,13 @@
         {
             QDomElement signal = list.item(j).toElement();
             QString signalName = signal.attribute(QLatin1String("name"));
-            if (signal.isNull() || signalName.isEmpty())
+            if (signal.isNull())
                 continue;
+            if (!QDBusUtil::isValidMemberName(signalName)) {
+                qWarning("Invalid D-BUS member name '%s' found in interface '%s' \
while parsing introspection", +                         qPrintable(signalName), \
qPrintable(ifaceName)); +                continue;
+            }
 
             QDBusIntrospection::Signal signalData;
             signalData.name = signalName;
@@ -172,8 +193,13 @@
         {
             QDomElement property = list.item(j).toElement();
             QString propertyName = property.attribute(QLatin1String("name"));
-            if (property.isNull() || propertyName.isEmpty())
+            if (property.isNull())
                 continue;
+            if (!QDBusUtil::isValidMemberName(propertyName)) {
+                qWarning("Invalid D-BUS member name '%s' found in interface '%s' \
while parsing introspection", +                         qPrintable(propertyName), \
qPrintable(ifaceName)); +                continue;
+            }
 
             QDBusIntrospection::Property propertyData;
 
@@ -182,22 +208,27 @@
             propertyData.type = property.attribute(QLatin1String("type"));
             propertyData.annotations = parseAnnotations(property);
 
-            if (!QDBusUtil::isValidSingleSignature(propertyData.type))
+            if (!QDBusUtil::isValidSingleSignature(propertyData.type)) {
                 // cannot be!
+                qWarning("Invalid D-BUS type signature '%s' found in property \
'%s.%s' while parsing introspection", +                         \
qPrintable(propertyData.type), qPrintable(ifaceName), +                         \
qPrintable(propertyName));  continue;
+            }
 
             QString access = property.attribute(QLatin1String("access"));
-            if (access.isEmpty())
-                // can't be empty either!
-                continue;
-            else if (access == QLatin1String("read"))
+            if (access == QLatin1String("read"))
                 propertyData.access = QDBusIntrospection::Property::Read;
             else if (access == QLatin1String("write"))
                 propertyData.access = QDBusIntrospection::Property::Write;
             else if (access == QLatin1String("readwrite"))
                 propertyData.access = QDBusIntrospection::Property::ReadWrite;
-            else
+            else {
+                qWarning("Invalid D-BUS property access '%s' found in property \
'%s.%s' while parsing introspection", +                         qPrintable(access), \
qPrintable(ifaceName), +                         qPrintable(propertyName));
                 continue;       // invalid one!
+            }
 
             // add it
             ifaceData->properties.insert(propertyName, propertyData);
@@ -231,8 +262,13 @@
         for (int i = 0; i < objects.count(); ++i) {
             QDomElement obj = objects.item(i).toElement();
             QString objName = obj.attribute(QLatin1String("name"));
-            if (obj.isNull() || objName.isEmpty())
+            if (obj.isNull())
                 continue;           // for whatever reason
+            if (!QDBusUtil::isValidObjectPath(m_path + QLatin1Char('/') + objName)) \
{ +                qWarning("Invalid D-BUS object path '%s/%s' found while parsing \
introspection", +                         qPrintable(m_path), qPrintable(objName));
+                continue;
+            }
 
             objData->childObjects.append(objName);
         }
@@ -241,8 +277,13 @@
         for (int i = 0; i < interfaceList.count(); ++i) {
             QDomElement iface = interfaceList.item(i).toElement();
             QString ifaceName = iface.attribute(QLatin1String("name"));
-            if (iface.isNull() || ifaceName.isEmpty())
+            if (iface.isNull())
                 continue;
+            if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
+                qWarning("Invalid D-BUS interface name '%s' found while parsing \
introspection", +                         qPrintable(ifaceName));
+                continue;
+            }
 
             objData->interfaces.append(ifaceName);
         }
--- trunk/kdesupport/qt-dbus/tools/dbus.cpp #548454:548455
@@ -136,7 +136,13 @@
     QDomElement child = node.firstChildElement();
     while (!child.isNull()) {
         if (child.tagName() == QLatin1String("interface")) {
-            listInterface(service, path, child.attribute("name"));
+            QString ifaceName = child.attribute("name");
+            if (QDBusUtil::isValidInterfaceName(ifaceName))
+                listInterface(service, path, ifaceName);
+            else {
+                qWarning("Invalid D-BUS interface name '%s' found while parsing \
introspection", +                         qPrintable(ifaceName));
+            }
         }
         child = child.nextSiblingElement();
     }
@@ -310,6 +316,14 @@
         member = interface.mid(pos + 1);
         interface.truncate(pos);
     }
+    if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
+        fprintf(stderr, "Interface '%s' is not a valid interface name.\n", \
qPrintable(interface)); +        exit(1);
+    }
+    if (!QDBusUtil::isValidMemberName(member)) {
+        fprintf(stderr, "Method name '%s' is not a valid member name.\n", \
qPrintable(member)); +        exit(1);
+    }
 
     placeCall(service, path, interface, member, argc - 4, argv + 4);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic