mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
D-Bus: Use a helper function to get possibly NULL strings
This type of check is used in quite a few getter functions, so add a helper function to take care of it. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
dbf524946b
commit
77fcbf7ff1
@ -516,6 +516,27 @@ dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wpas_dbus_string_property_getter - Get string type property
|
||||||
|
* @iter: Message iter to use when appending arguments
|
||||||
|
* @val: Pointer to place holding property value, can be %NULL
|
||||||
|
* @error: On failure an error describing the failure
|
||||||
|
* Returns: TRUE if the request was successful, FALSE if it failed
|
||||||
|
*
|
||||||
|
* Generic getter for string type properties. %NULL is converted to an empty
|
||||||
|
* string.
|
||||||
|
*/
|
||||||
|
dbus_bool_t wpas_dbus_string_property_getter(DBusMessageIter *iter,
|
||||||
|
const void *val,
|
||||||
|
DBusError *error)
|
||||||
|
{
|
||||||
|
if (!val)
|
||||||
|
val = "";
|
||||||
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
||||||
|
&val, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wpas_dbus_handler_create_interface - Request registration of a network iface
|
* wpas_dbus_handler_create_interface - Request registration of a network iface
|
||||||
* @message: Pointer to incoming dbus message
|
* @message: Pointer to incoming dbus message
|
||||||
@ -3086,10 +3107,8 @@ dbus_bool_t wpas_dbus_getter_ifname(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
const char *ifname = wpa_s->ifname;
|
|
||||||
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
return wpas_dbus_string_property_getter(iter, wpa_s->ifname, error);
|
||||||
&ifname, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3107,7 +3126,6 @@ dbus_bool_t wpas_dbus_getter_driver(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
const char *driver;
|
|
||||||
|
|
||||||
if (wpa_s->driver == NULL || wpa_s->driver->name == NULL) {
|
if (wpa_s->driver == NULL || wpa_s->driver->name == NULL) {
|
||||||
wpa_printf(MSG_DEBUG, "%s[dbus]: wpa_s has no driver set",
|
wpa_printf(MSG_DEBUG, "%s[dbus]: wpa_s has no driver set",
|
||||||
@ -3117,9 +3135,8 @@ dbus_bool_t wpas_dbus_getter_driver(
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver = wpa_s->driver->name;
|
return wpas_dbus_string_property_getter(iter, wpa_s->driver->name,
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
error);
|
||||||
&driver, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3232,10 +3249,9 @@ dbus_bool_t wpas_dbus_getter_bridge_ifname(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
const char *bridge_ifname = wpa_s->bridge_ifname;
|
|
||||||
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
return wpas_dbus_string_property_getter(iter, wpa_s->bridge_ifname,
|
||||||
&bridge_ifname, error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3253,13 +3269,8 @@ dbus_bool_t wpas_dbus_getter_config_file(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *confname = "";
|
|
||||||
|
|
||||||
if (wpa_s->confname)
|
return wpas_dbus_string_property_getter(iter, wpa_s->confname, error);
|
||||||
confname = wpa_s->confname;
|
|
||||||
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&confname, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3399,14 +3410,10 @@ dbus_bool_t wpas_dbus_getter_pkcs11_engine_path(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
const char *pkcs11_engine_path;
|
|
||||||
|
|
||||||
if (wpa_s->conf->pkcs11_engine_path == NULL)
|
return wpas_dbus_string_property_getter(iter,
|
||||||
pkcs11_engine_path = "";
|
wpa_s->conf->pkcs11_engine_path,
|
||||||
else
|
error);
|
||||||
pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&pkcs11_engine_path, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3424,14 +3431,10 @@ dbus_bool_t wpas_dbus_getter_pkcs11_module_path(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
const char *pkcs11_module_path;
|
|
||||||
|
|
||||||
if (wpa_s->conf->pkcs11_module_path == NULL)
|
return wpas_dbus_string_property_getter(iter,
|
||||||
pkcs11_module_path = "";
|
wpa_s->conf->pkcs11_module_path,
|
||||||
else
|
error);
|
||||||
pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&pkcs11_module_path, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,10 @@ dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
|
|||||||
size_t array_len,
|
size_t array_len,
|
||||||
DBusError *error);
|
DBusError *error);
|
||||||
|
|
||||||
|
dbus_bool_t wpas_dbus_string_property_getter(DBusMessageIter *iter,
|
||||||
|
const void *val,
|
||||||
|
DBusError *error);
|
||||||
|
|
||||||
DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
|
DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
|
||||||
struct wpa_global *global);
|
struct wpa_global *global);
|
||||||
|
|
||||||
|
@ -2352,19 +2352,12 @@ dbus_bool_t wpas_dbus_getter_p2p_group_passphrase(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *p_pass;
|
|
||||||
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
||||||
|
|
||||||
if (ssid == NULL)
|
if (ssid == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
p_pass = ssid->passphrase;
|
return wpas_dbus_string_property_getter(iter, ssid->passphrase, error);
|
||||||
if (!p_pass)
|
|
||||||
p_pass = "";
|
|
||||||
|
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&p_pass, error);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,12 +412,10 @@ dbus_bool_t wpas_dbus_getter_config_methods(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *methods = wpa_s->conf->config_methods;
|
|
||||||
|
|
||||||
if (methods == NULL)
|
return wpas_dbus_string_property_getter(iter,
|
||||||
methods = "";
|
wpa_s->conf->config_methods,
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
error);
|
||||||
&methods, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -470,12 +468,9 @@ dbus_bool_t wpas_dbus_getter_wps_device_name(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *methods = wpa_s->conf->device_name;
|
|
||||||
|
|
||||||
if (!methods)
|
return wpas_dbus_string_property_getter(iter, wpa_s->conf->device_name,
|
||||||
methods = "";
|
error);
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&methods, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -529,12 +524,9 @@ dbus_bool_t wpas_dbus_getter_wps_manufacturer(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *manufacturer = wpa_s->conf->manufacturer;
|
|
||||||
|
|
||||||
if (!manufacturer)
|
return wpas_dbus_string_property_getter(iter, wpa_s->conf->manufacturer,
|
||||||
manufacturer = "";
|
error);
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&manufacturer, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,12 +580,9 @@ dbus_bool_t wpas_dbus_getter_wps_device_model_name(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *model_name = wpa_s->conf->model_name;
|
|
||||||
|
|
||||||
if (!model_name)
|
return wpas_dbus_string_property_getter(iter, wpa_s->conf->model_name,
|
||||||
model_name = "";
|
error);
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&model_name, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -646,12 +635,9 @@ dbus_bool_t wpas_dbus_getter_wps_device_model_number(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *model_number = wpa_s->conf->model_number;
|
|
||||||
|
|
||||||
if (!model_number)
|
return wpas_dbus_string_property_getter(iter, wpa_s->conf->model_number,
|
||||||
model_number = "";
|
error);
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
||||||
&model_number, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -705,12 +691,10 @@ dbus_bool_t wpas_dbus_getter_wps_device_serial_number(
|
|||||||
DBusMessageIter *iter, DBusError *error, void *user_data)
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = user_data;
|
struct wpa_supplicant *wpa_s = user_data;
|
||||||
char *model_number = wpa_s->conf->serial_number;
|
|
||||||
|
|
||||||
if (!model_number)
|
return wpas_dbus_string_property_getter(iter,
|
||||||
model_number = "";
|
wpa_s->conf->serial_number,
|
||||||
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
error);
|
||||||
&model_number, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user