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