From dddd870d16b45eaadef3d1eaaa4a06da519bc7f0 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 27 Dec 2014 13:14:03 +0200 Subject: [PATCH] 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 --- wpa_supplicant/dbus/dbus_old_handlers_wps.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/dbus/dbus_old_handlers_wps.c b/wpa_supplicant/dbus/dbus_old_handlers_wps.c index bb7938246..6c1c13b71 100644 --- a/wpa_supplicant/dbus/dbus_old_handlers_wps.c +++ b/wpa_supplicant/dbus/dbus_old_handlers_wps.c @@ -73,6 +73,7 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message, char *pin = NULL; u8 bssid[ETH_ALEN], *_bssid = NULL; int ret = 0; + char npin[9]; if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid, DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID)) @@ -104,15 +105,12 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message, if (reply == NULL) return NULL; - if (ret == 0) { - dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin, - DBUS_TYPE_INVALID); - } else { - char npin[9]; + if (ret > 0) { os_snprintf(npin, sizeof(npin), "%08d", ret); - dbus_message_append_args(reply, DBUS_TYPE_STRING, &npin, - DBUS_TYPE_INVALID); + pin = npin; } + dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin, + DBUS_TYPE_INVALID); return reply; }