D-Bus(old): Fix WPS interface for PIN from wpa_supplicant case

dbus_message_append_args() needs char** and &npin ended up being char*
and resulted in segmentation fault.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-27 13:14:03 +02:00
parent 5f136bc126
commit dddd870d16

View file

@ -73,6 +73,7 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
char *pin = NULL; char *pin = NULL;
u8 bssid[ETH_ALEN], *_bssid = NULL; u8 bssid[ETH_ALEN], *_bssid = NULL;
int ret = 0; int ret = 0;
char npin[9];
if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid, if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID)) DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
@ -104,15 +105,12 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
if (reply == NULL) if (reply == NULL)
return NULL; return NULL;
if (ret == 0) { if (ret > 0) {
dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin,
DBUS_TYPE_INVALID);
} else {
char npin[9];
os_snprintf(npin, sizeof(npin), "%08d", ret); os_snprintf(npin, sizeof(npin), "%08d", ret);
dbus_message_append_args(reply, DBUS_TYPE_STRING, &npin, pin = npin;
DBUS_TYPE_INVALID);
} }
dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin,
DBUS_TYPE_INVALID);
return reply; return reply;
} }