diff --git a/plugins/push-notification.c b/plugins/push-notification.c index ff388d9e..f469f9ed 100644 --- a/plugins/push-notification.c +++ b/plugins/push-notification.c @@ -96,7 +96,7 @@ static DBusMessage *push_notification_register_agent(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); pn->agent = sms_agent_new(AGENT_INTERFACE, diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c index bbbdaa9d..0c9700d2 100644 --- a/plugins/smart-messaging.c +++ b/plugins/smart-messaging.c @@ -119,7 +119,7 @@ static DBusMessage *smart_messaging_register_agent(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); sm->agent = sms_agent_new(AGENT_INTERFACE, diff --git a/src/dbus.c b/src/dbus.c index 45becc15..3e1e162a 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -456,50 +456,6 @@ void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply) *msg = NULL; } -gboolean __ofono_dbus_valid_object_path(const char *path) -{ - unsigned int i; - char c = '\0'; - - if (path == NULL) - return FALSE; - - if (path[0] == '\0') - return FALSE; - - if (path[0] && !path[1] && path[0] == '/') - return TRUE; - - if (path[0] != '/') - return FALSE; - - for (i = 0; path[i]; i++) { - if (path[i] == '/' && c == '/') - return FALSE; - - c = path[i]; - - if (path[i] >= 'a' && path[i] <= 'z') - continue; - - if (path[i] >= 'A' && path[i] <= 'Z') - continue; - - if (path[i] >= '0' && path[i] <= '9') - continue; - - if (path[i] == '_' || path[i] == '/') - continue; - - return FALSE; - } - - if (path[i-1] == '/') - return FALSE; - - return TRUE; -} - DBusConnection *ofono_dbus_get_connection(void) { return g_connection; diff --git a/src/gnss.c b/src/gnss.c index 97d11527..ba2a97b7 100644 --- a/src/gnss.c +++ b/src/gnss.c @@ -135,7 +135,7 @@ static DBusMessage *gnss_register_agent(DBusConnection *conn, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); gnss->posr_agent = gnss_agent_new(agent_path, diff --git a/src/modem.c b/src/modem.c index 0c63d2c2..d5fda7ca 100644 --- a/src/modem.c +++ b/src/modem.c @@ -1876,7 +1876,7 @@ struct ofono_modem *ofono_modem_create(const char *name, const char *type) else snprintf(path, sizeof(path), "/%s", name); - if (__ofono_dbus_valid_object_path(path) == FALSE) + if (!dbus_validate_path(path, NULL)) return NULL; modem = g_try_new0(struct ofono_modem, 1); diff --git a/src/netmon.c b/src/netmon.c index 3a495873..62e0ec0b 100644 --- a/src/netmon.c +++ b/src/netmon.c @@ -353,7 +353,7 @@ static DBusMessage *netmon_register_agent(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); if (!period) diff --git a/src/ofono.h b/src/ofono.h index deb1b7c4..ac3726d5 100644 --- a/src/ofono.h +++ b/src/ofono.h @@ -76,8 +76,6 @@ DBusMessage *__ofono_error_from_error(const struct ofono_error *error, void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply); -gboolean __ofono_dbus_valid_object_path(const char *path); - struct ofono_watchlist_item { unsigned int id; void *notify; diff --git a/src/stk.c b/src/stk.c index 49d6365f..9cdf2b1e 100644 --- a/src/stk.c +++ b/src/stk.c @@ -722,7 +722,7 @@ static DBusMessage *stk_register_agent(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); stk->default_agent = stk_agent_new(agent_path, @@ -834,7 +834,7 @@ static DBusMessage *stk_select_item(DBusConnection *conn, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); - if (!__ofono_dbus_valid_object_path(agent_path)) + if (!dbus_validate_path(agent_path, NULL)) return __ofono_error_invalid_format(msg); for (i = 0; i < selection && menu->items[i].text; i++);