dbus: Use dbus_validate_path

Instead of __ofono_dbus_valid_object_path
This commit is contained in:
Slava Monich 2018-01-18 18:47:57 +02:00 committed by Denis Kenzior
parent f7544d87a3
commit 0797b23c5d
8 changed files with 7 additions and 53 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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++);