From: Reinette Chatre Date: Tue, 13 Sep 2011 16:27:29 +0000 (-0700) Subject: D-Bus/P2P: Treat PIN as string X-Git-Tag: hostap-1-bp~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97a8cbb88d2985ecd886d3bc56caa728c1ca1117;p=thirdparty%2Fhostap.git D-Bus/P2P: Treat PIN as string wpa_supplicant returns the PIN in reply to the connect method. Treating this value as an integer runs the risk of not returning the correct value if the first digit(s) happens to be a zero(es). To return the correct PIN it needs to be returned as a string. Signed-off-by: Reinette Chatre Signed-off-by: Angie Chinchilla --- diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index f3a74e896..39cf40155 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2204,7 +2204,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = { (WPADBusMethodHandler)wpas_dbus_handler_p2p_connect, { { "args", "a{sv}", ARG_IN }, - { "generated_pin", "i", ARG_OUT }, + { "generated_pin", "s", ARG_OUT }, END_ARGS } }, diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c index f9c7cdcdb..0ab755396 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c +++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c @@ -510,9 +510,13 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message, go_intent, freq); if (new_pin >= 0) { + char npin[9]; + char *generated_pin; + os_snprintf(npin, sizeof(npin), "%08d", new_pin); + generated_pin = npin; reply = dbus_message_new_method_return(message); - dbus_message_append_args(reply, DBUS_TYPE_INT32, - &new_pin, DBUS_TYPE_INVALID); + dbus_message_append_args(reply, DBUS_TYPE_STRING, + &generated_pin, DBUS_TYPE_INVALID); } else { switch (new_pin) { case -2: