[PATCH] D-Bus/P2P: treat PIN as string

Angie Chinchilla angie.v.chinchilla at intel.com
Tue Sep 13 12:27:29 EDT 2011


From: Reinette Chatre <reinette.chatre at intel.com>

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 <reinette.chatre at intel.com>
Signed-off-by: Angie Chinchilla <angie.v.chinchilla at intel.com>
---
 wpa_supplicant/dbus/dbus_new.c              |    2 +-
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index e488937..4b7ae0d 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 06e653e..3c1b414 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -501,9 +501,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:
-- 
1.7.0.4



More information about the HostAP mailing list