dbus library calls abort() if it got a non-expected type passed to it. --- Changelog: v3: Fix embarrassing typo v2: Check against specific type instead of all basic types
src/agent-connman.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/src/agent-connman.c b/src/agent-connman.c index 2d714b5..341e253 100644 --- a/src/agent-connman.c +++ b/src/agent-connman.c @@ -110,7 +110,14 @@ static void request_input_passphrase_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &identity); } else if (g_str_equal(key, "Passphrase")) { @@ -118,7 +125,14 @@ static void request_input_passphrase_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &passphrase); } else if (g_str_equal(key, "WPS")) { @@ -128,7 +142,14 @@ static void request_input_passphrase_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &wpspin); break; } else if (g_str_equal(key, "Name")) { @@ -136,7 +157,14 @@ static void request_input_passphrase_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &name); name_len = strlen(name); } else if (g_str_equal(key, "SSID")) { @@ -144,16 +172,25 @@ static void request_input_passphrase_reply(DBusMessage *reply, void *user_data) dbus_message_iter_next(&entry); if (dbus_message_iter_get_arg_type(&entry) - != DBUS_TYPE_VARIANT) + != DBUS_TYPE_VARIANT) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; break; + } dbus_message_iter_recurse(&entry, &value); if (dbus_message_iter_get_arg_type(&value) - != DBUS_TYPE_ARRAY) + != DBUS_TYPE_ARRAY) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; break; + } dbus_message_iter_recurse(&value, &array_iter); if (dbus_message_iter_get_arg_type(&array_iter) - != DBUS_TYPE_BYTE) + != DBUS_TYPE_BYTE) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; break; + } dbus_message_iter_get_fixed_array(&array_iter, &name, &name_len); } @@ -401,7 +438,14 @@ static void request_input_login_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &username); } else if (g_str_equal(key, "Password")) { @@ -409,7 +453,14 @@ static void request_input_login_reply(DBusMessage *reply, void *user_data) if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + values_received = false; + break; + } + dbus_message_iter_get_basic(&value, &password); } @@ -717,7 +768,13 @@ static void request_peer_authorization_reply(DBusMessage *reply, if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; + dbus_message_iter_recurse(&entry, &value); + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) { + error = CONNMAN_ERROR_INTERFACE ".InvalidArguments"; + break; + } + dbus_message_iter_get_basic(&value, &wpspin); break; } -- 1.9.1 _______________________________________________ connman mailing list connman@connman.net https://lists.connman.net/mailman/listinfo/connman