chiark / gitweb /
bus-proxy: avoid redundant name validity checks
authorLennart Poettering <lennart@poettering.net>
Fri, 14 Nov 2014 19:06:20 +0000 (20:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 14 Nov 2014 19:06:20 +0000 (20:06 +0100)
Our API calls check the validity of bus names anyway, hence we don't
have to do this before calling them...

src/bus-proxyd/bus-proxyd.c

index 7037301..9c4f2a6 100644 (file)
@@ -412,8 +412,6 @@ static int get_creds_by_name(sd_bus *bus, const char *name, uint64_t mask, sd_bu
         assert(name);
         assert(_creds);
 
-        assert_return(service_name_is_valid(name), -EINVAL);
-
         r = sd_bus_get_name_creds(bus, name, mask, &c);
         if (r == -ESRCH || r == -ENXIO)
                 return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", name);
@@ -769,9 +767,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(arg0))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 r = sd_bus_get_name_creds(a, arg0, 0, NULL);
                 if (r == -ESRCH || r == -ENXIO) {
                         sd_bus_error_setf(&error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Could not get owners of name '%s': no such name.", arg0);
@@ -830,9 +825,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 if (streq(name, "org.freedesktop.DBus"))
                         return synthetic_reply_method_return(m, "b", true);
 
@@ -849,9 +841,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 r = sd_bus_release_name(a, name);
                 if (r < 0) {
                         if (r == -ESRCH)
@@ -885,8 +874,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (policy && !policy_check_own(policy, ucred, name))
                         return synthetic_reply_method_errno(m, -EPERM, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
                 if ((flags & ~(BUS_NAME_ALLOW_REPLACEMENT|BUS_NAME_REPLACE_EXISTING|BUS_NAME_DO_NOT_QUEUE)) != 0)
                         return synthetic_reply_method_errno(m, -EINVAL, NULL);
 
@@ -927,8 +914,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
                 if (flags != 0)
                         return synthetic_reply_method_errno(m, -EINVAL, NULL);