dbus: Use os_*() wrappers for memory allocations consistently
This is needed to avoid bogus WPA_TRACE error reports.
This commit is contained in:
parent
719347511a
commit
a646086d51
5 changed files with 36 additions and 34 deletions
|
@ -300,7 +300,7 @@ char * wpas_dbus_decompose_object_path(const char *path, char **network,
|
|||
if ((path + dev_path_prefix_len)[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
obj_path_only = strdup(path);
|
||||
obj_path_only = os_strdup(path);
|
||||
if (obj_path_only == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -317,13 +317,13 @@ char * wpas_dbus_decompose_object_path(const char *path, char **network,
|
|||
strlen(WPAS_DBUS_NETWORKS_PART "/");
|
||||
*network = NULL;
|
||||
if (strlen(net_name))
|
||||
*network = strdup(net_name);
|
||||
*network = os_strdup(net_name);
|
||||
} else if (bssid && bssid_part) {
|
||||
/* Deal with a request for a scanned BSSID */
|
||||
const char *bssid_name = bssid_part +
|
||||
strlen(WPAS_DBUS_BSSIDS_PART "/");
|
||||
if (strlen(bssid_name))
|
||||
*bssid = strdup(bssid_name);
|
||||
*bssid = os_strdup(bssid_name);
|
||||
else
|
||||
*bssid = NULL;
|
||||
}
|
||||
|
@ -565,9 +565,9 @@ static DBusHandlerResult wpas_iface_message_handler(DBusConnection *connection,
|
|||
}
|
||||
|
||||
out:
|
||||
free(iface_obj_path);
|
||||
free(network);
|
||||
free(bssid);
|
||||
os_free(iface_obj_path);
|
||||
os_free(network);
|
||||
os_free(bssid);
|
||||
return reply ? DBUS_HANDLER_RESULT_HANDLED :
|
||||
DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
@ -1045,7 +1045,7 @@ void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
|
|||
}
|
||||
|
||||
memset(iface, 0, sizeof(struct ctrl_iface_dbus_priv));
|
||||
free(iface);
|
||||
os_free(iface);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
|
|||
ret = 0;
|
||||
|
||||
out:
|
||||
free(path);
|
||||
os_free(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1130,7 @@ int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
|
|||
if (!dbus_connection_unregister_object_path(con, path))
|
||||
return -1;
|
||||
|
||||
free(wpa_s->dbus_path);
|
||||
os_free(wpa_s->dbus_path);
|
||||
wpa_s->dbus_path = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -1170,7 +1170,7 @@ int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
|
|||
return -1;
|
||||
if (wpa_s->dbus_path)
|
||||
return -1;
|
||||
wpa_s->dbus_path = strdup(path);
|
||||
wpa_s->dbus_path = os_strdup(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
|
|||
char byte;
|
||||
|
||||
if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
|
||||
buffer = realloc(buffer, BYTE_ARRAY_ITEM_SIZE *
|
||||
buffer = os_realloc(buffer, BYTE_ARRAY_ITEM_SIZE *
|
||||
(count + BYTE_ARRAY_CHUNK_SIZE));
|
||||
if (buffer == NULL) {
|
||||
perror("_wpa_dbus_dict_entry_get_byte_array["
|
||||
|
@ -673,7 +673,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
|
|||
|
||||
/* Zero-length arrays are valid. */
|
||||
if (entry->array_len == 0) {
|
||||
free(entry->bytearray_value);
|
||||
os_free(entry->bytearray_value);
|
||||
entry->bytearray_value = NULL;
|
||||
}
|
||||
|
||||
|
@ -712,7 +712,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
|
|||
char *str;
|
||||
|
||||
if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
|
||||
buffer = realloc(buffer, STR_ARRAY_ITEM_SIZE *
|
||||
buffer = os_realloc(buffer, STR_ARRAY_ITEM_SIZE *
|
||||
(count + STR_ARRAY_CHUNK_SIZE));
|
||||
if (buffer == NULL) {
|
||||
perror("_wpa_dbus_dict_entry_get_string_array["
|
||||
|
@ -724,7 +724,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
|
|||
entry->strarray_value = buffer;
|
||||
|
||||
dbus_message_iter_get_basic(iter, &value);
|
||||
str = strdup(value);
|
||||
str = os_strdup(value);
|
||||
if (str == NULL) {
|
||||
perror("_wpa_dbus_dict_entry_get_string_array[dbus] "
|
||||
"out of memory trying to duplicate the string "
|
||||
|
@ -738,7 +738,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
|
|||
|
||||
/* Zero-length arrays are valid. */
|
||||
if (entry->array_len == 0) {
|
||||
free(entry->strarray_value);
|
||||
os_free(entry->strarray_value);
|
||||
entry->strarray_value = NULL;
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ static dbus_bool_t _wpa_dbus_dict_fill_value_from_variant(
|
|||
case DBUS_TYPE_STRING: {
|
||||
const char *v;
|
||||
dbus_message_iter_get_basic(iter_dict_val, &v);
|
||||
entry->str_value = strdup(v);
|
||||
entry->str_value = os_strdup(v);
|
||||
break;
|
||||
}
|
||||
case DBUS_TYPE_BOOLEAN: {
|
||||
|
@ -849,7 +849,7 @@ static dbus_bool_t _wpa_dbus_dict_fill_value_from_variant(
|
|||
case DBUS_TYPE_OBJECT_PATH: {
|
||||
char *v;
|
||||
dbus_message_iter_get_basic(iter_dict_val, &v);
|
||||
entry->str_value = strdup(v);
|
||||
entry->str_value = os_strdup(v);
|
||||
break;
|
||||
}
|
||||
case DBUS_TYPE_ARRAY: {
|
||||
|
@ -956,17 +956,17 @@ void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry *entry)
|
|||
switch (entry->type) {
|
||||
case DBUS_TYPE_OBJECT_PATH:
|
||||
case DBUS_TYPE_STRING:
|
||||
free(entry->str_value);
|
||||
os_free(entry->str_value);
|
||||
break;
|
||||
case DBUS_TYPE_ARRAY:
|
||||
switch (entry->array_type) {
|
||||
case DBUS_TYPE_BYTE:
|
||||
free(entry->bytearray_value);
|
||||
os_free(entry->bytearray_value);
|
||||
break;
|
||||
case DBUS_TYPE_STRING:
|
||||
for (i = 0; i < entry->array_len; i++)
|
||||
free(entry->strarray_value[i]);
|
||||
free(entry->strarray_value);
|
||||
os_free(entry->strarray_value[i]);
|
||||
os_free(entry->strarray_value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -129,22 +129,24 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message,
|
|||
goto error;
|
||||
if (!strcmp(entry.key, "driver") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.driver = strdup(entry.str_value);
|
||||
iface.driver = os_strdup(entry.str_value);
|
||||
if (iface.driver == NULL)
|
||||
goto error;
|
||||
} else if (!strcmp(entry.key, "driver-params") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.driver_param = strdup(entry.str_value);
|
||||
iface.driver_param =
|
||||
os_strdup(entry.str_value);
|
||||
if (iface.driver_param == NULL)
|
||||
goto error;
|
||||
} else if (!strcmp(entry.key, "config-file") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.confname = strdup(entry.str_value);
|
||||
iface.confname = os_strdup(entry.str_value);
|
||||
if (iface.confname == NULL)
|
||||
goto error;
|
||||
} else if (!strcmp(entry.key, "bridge-ifname") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.bridge_ifname = strdup(entry.str_value);
|
||||
iface.bridge_ifname =
|
||||
os_strdup(entry.str_value);
|
||||
if (iface.bridge_ifname == NULL)
|
||||
goto error;
|
||||
} else {
|
||||
|
|
|
@ -1161,7 +1161,7 @@ static int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
|
|||
wpas_dbus_getter_enabled,
|
||||
(WPADBusPropertyAccessor)
|
||||
wpas_dbus_setter_enabled,
|
||||
arg1, free, RW);
|
||||
arg1, os_free, RW);
|
||||
|
||||
/* Properties property */
|
||||
wpa_dbus_property_register(obj_desc, WPAS_DBUS_NEW_IFACE_NETWORK,
|
||||
|
@ -1170,7 +1170,7 @@ static int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
|
|||
wpas_dbus_getter_network_properties,
|
||||
(WPADBusPropertyAccessor)
|
||||
wpas_dbus_setter_network_properties,
|
||||
arg2, free, RW);
|
||||
arg2, os_free, RW);
|
||||
|
||||
/* PropertiesChanged signal */
|
||||
wpa_dbus_signal_register(obj_desc, WPAS_DBUS_NEW_IFACE_NETWORK,
|
||||
|
@ -1329,7 +1329,7 @@ static int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
|
|||
"Properties", "a{sv}",
|
||||
(WPADBusPropertyAccessor)
|
||||
wpas_dbus_getter_bss_properties, NULL,
|
||||
arg, free, R);
|
||||
arg, os_free, R);
|
||||
|
||||
if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
|
||||
wpa_s->ifname, obj_desc)) {
|
||||
|
|
|
@ -375,17 +375,17 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
|
|||
goto error;
|
||||
if (!strcmp(entry.key, "Driver") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.driver = strdup(entry.str_value);
|
||||
iface.driver = os_strdup(entry.str_value);
|
||||
if (iface.driver == NULL)
|
||||
goto error;
|
||||
} else if (!strcmp(entry.key, "Ifname") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.ifname = strdup(entry.str_value);
|
||||
iface.ifname = os_strdup(entry.str_value);
|
||||
if (iface.ifname == NULL)
|
||||
goto error;
|
||||
} else if (!strcmp(entry.key, "BridgeIfname") &&
|
||||
(entry.type == DBUS_TYPE_STRING)) {
|
||||
iface.bridge_ifname = strdup(entry.str_value);
|
||||
iface.bridge_ifname = os_strdup(entry.str_value);
|
||||
if (iface.bridge_ifname == NULL)
|
||||
goto error;
|
||||
} else {
|
||||
|
@ -1512,7 +1512,7 @@ DBusMessage * wpas_dbus_handler_add_blob(DBusMessage *message,
|
|||
os_memcpy(blob->data, blob_data, blob_len);
|
||||
|
||||
blob->len = blob_len;
|
||||
blob->name = strdup(blob_name);
|
||||
blob->name = os_strdup(blob_name);
|
||||
if (!blob->name) {
|
||||
perror("wpas_dbus_handler_add_blob[dbus] out of memory when "
|
||||
"trying to copy blob name");
|
||||
|
|
Loading…
Reference in a new issue