dbus: Check return value more consistently (CID 62841)

Most of these calls are checked to return success and there is no reason
why these wouldn't, so be more consistent. This addresses CID 62841,
CID 62840, CID 62839, CID 62838, CID 62837, CID 62836.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-06-14 01:29:42 +03:00
parent ac79fcfa76
commit 25be28a375
3 changed files with 39 additions and 22 deletions

View File

@ -440,8 +440,13 @@ dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
}
for (i = 0; i < array_len; i++) {
dbus_message_iter_append_basic(&array_iter, type,
array + i * element_size);
if (!dbus_message_iter_append_basic(&array_iter, type,
array + i * element_size)) {
dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 2.5",
__func__);
return FALSE;
}
}
if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {

View File

@ -38,27 +38,25 @@ static dbus_bool_t fill_dict_with_properties(
if (!dbus_message_iter_open_container(dict_iter,
DBUS_TYPE_DICT_ENTRY,
NULL, &entry_iter)) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
"no memory");
return FALSE;
}
if (!dbus_message_iter_append_basic(&entry_iter,
NULL, &entry_iter) ||
!dbus_message_iter_append_basic(&entry_iter,
DBUS_TYPE_STRING,
&dsc->dbus_property)) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
"no memory");
return FALSE;
}
&dsc->dbus_property))
goto error;
/* An error getting a property fails the request entirely */
if (!dsc->getter(&entry_iter, error, user_data))
return FALSE;
dbus_message_iter_close_container(dict_iter, &entry_iter);
if (!dbus_message_iter_close_container(dict_iter, &entry_iter))
goto error;
}
return TRUE;
error:
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
return FALSE;
}
@ -111,7 +109,12 @@ static DBusMessage * get_all_properties(DBusMessage *message, char *interface,
return reply;
}
wpa_dbus_dict_close_write(&iter, &dict_iter);
if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
dbus_message_unref(reply);
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
"out of memory");
}
return reply;
}

View File

@ -350,7 +350,7 @@ DBusMessage * wpas_dbus_iface_scan(DBusMessage *message,
DBusMessage * wpas_dbus_iface_scan_results(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
DBusMessage *reply = NULL;
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter sub_iter;
struct wpa_bss *bss;
@ -358,9 +358,10 @@ DBusMessage * wpas_dbus_iface_scan_results(DBusMessage *message,
/* Create and initialize the return message */
reply = dbus_message_new_method_return(message);
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH_AS_STRING,
&sub_iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH_AS_STRING,
&sub_iter))
goto error;
/* Loop through scan results and append each result's object path */
dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) {
@ -374,13 +375,21 @@ DBusMessage * wpas_dbus_iface_scan_results(DBusMessage *message,
"%s/" WPAS_DBUS_BSSIDS_PART "/"
WPAS_DBUS_BSSID_FORMAT,
wpa_s->dbus_path, MAC2STR(bss->bssid));
dbus_message_iter_append_basic(&sub_iter,
DBUS_TYPE_OBJECT_PATH, &path);
if (!dbus_message_iter_append_basic(&sub_iter,
DBUS_TYPE_OBJECT_PATH,
&path))
goto error;
}
dbus_message_iter_close_container(&iter, &sub_iter);
if (!dbus_message_iter_close_container(&iter, &sub_iter))
goto error;
return reply;
error:
dbus_message_unref(reply);
return dbus_message_new_error(message, WPAS_ERROR_INTERNAL_ERROR,
"an internal error occurred returning scan results");
}