mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-17 18:34:03 -05:00
dbus: Clean up error reporting for TDLS peer address parsing
Passing a pointer to an error reply message is not very robust since memory allocation could fail even for that error message. Instead, use a separate error value as the return value from get_peer_hwaddr_helper() and return a pointer to the error message through a pointer-to-pointer so that the error case will always be clear. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
3b6170b78d
commit
508e24c20b
@ -1995,25 +1995,29 @@ DBusMessage * wpas_dbus_handler_eap_logon(DBusMessage *message,
|
|||||||
|
|
||||||
#ifdef CONFIG_TDLS
|
#ifdef CONFIG_TDLS
|
||||||
|
|
||||||
static DBusMessage * get_peer_hwaddr_helper(DBusMessage *message,
|
static int get_peer_hwaddr_helper(DBusMessage *message, const char *func_name,
|
||||||
const char *func_name,
|
u8 *peer_address, DBusMessage **error)
|
||||||
u8 *peer_address)
|
|
||||||
{
|
{
|
||||||
const char *peer_string;
|
const char *peer_string;
|
||||||
|
|
||||||
|
*error = NULL;
|
||||||
|
|
||||||
if (!dbus_message_get_args(message, NULL,
|
if (!dbus_message_get_args(message, NULL,
|
||||||
DBUS_TYPE_STRING, &peer_string,
|
DBUS_TYPE_STRING, &peer_string,
|
||||||
DBUS_TYPE_INVALID))
|
DBUS_TYPE_INVALID)) {
|
||||||
return wpas_dbus_error_invalid_args(message, NULL);
|
*error = wpas_dbus_error_invalid_args(message, NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (hwaddr_aton(peer_string, peer_address)) {
|
if (hwaddr_aton(peer_string, peer_address)) {
|
||||||
wpa_printf(MSG_DEBUG, "%s: invalid address '%s'",
|
wpa_printf(MSG_DEBUG, "%s: invalid address '%s'",
|
||||||
func_name, peer_string);
|
func_name, peer_string);
|
||||||
return wpas_dbus_error_invalid_args(
|
*error = wpas_dbus_error_invalid_args(
|
||||||
message, "Invalid hardware address format");
|
message, "Invalid hardware address format");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2032,8 +2036,7 @@ DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
|
|||||||
DBusMessage *error_reply;
|
DBusMessage *error_reply;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
error_reply = get_peer_hwaddr_helper(message, __func__, peer);
|
if (get_peer_hwaddr_helper(message, __func__, peer, &error_reply) < 0)
|
||||||
if (error_reply)
|
|
||||||
return error_reply;
|
return error_reply;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "DBUS TDLS_DISCOVER " MACSTR, MAC2STR(peer));
|
wpa_printf(MSG_DEBUG, "DBUS TDLS_DISCOVER " MACSTR, MAC2STR(peer));
|
||||||
@ -2067,8 +2070,7 @@ DBusMessage * wpas_dbus_handler_tdls_setup(DBusMessage *message,
|
|||||||
DBusMessage *error_reply;
|
DBusMessage *error_reply;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
error_reply = get_peer_hwaddr_helper(message, __func__, peer);
|
if (get_peer_hwaddr_helper(message, __func__, peer, &error_reply) < 0)
|
||||||
if (error_reply)
|
|
||||||
return error_reply;
|
return error_reply;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "DBUS TDLS_SETUP " MACSTR, MAC2STR(peer));
|
wpa_printf(MSG_DEBUG, "DBUS TDLS_SETUP " MACSTR, MAC2STR(peer));
|
||||||
@ -2103,8 +2105,7 @@ DBusMessage * wpas_dbus_handler_tdls_status(DBusMessage *message,
|
|||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
const char *tdls_status;
|
const char *tdls_status;
|
||||||
|
|
||||||
reply = get_peer_hwaddr_helper(message, __func__, peer);
|
if (get_peer_hwaddr_helper(message, __func__, peer, &reply) < 0)
|
||||||
if (reply)
|
|
||||||
return reply;
|
return reply;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "DBUS TDLS_STATUS " MACSTR, MAC2STR(peer));
|
wpa_printf(MSG_DEBUG, "DBUS TDLS_STATUS " MACSTR, MAC2STR(peer));
|
||||||
@ -2133,8 +2134,7 @@ DBusMessage * wpas_dbus_handler_tdls_teardown(DBusMessage *message,
|
|||||||
DBusMessage *error_reply;
|
DBusMessage *error_reply;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
error_reply = get_peer_hwaddr_helper(message, __func__, peer);
|
if (get_peer_hwaddr_helper(message, __func__, peer, &error_reply) < 0)
|
||||||
if (error_reply)
|
|
||||||
return error_reply;
|
return error_reply;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "DBUS TDLS_TEARDOWN " MACSTR, MAC2STR(peer));
|
wpa_printf(MSG_DEBUG, "DBUS TDLS_TEARDOWN " MACSTR, MAC2STR(peer));
|
||||||
|
Loading…
Reference in New Issue
Block a user