]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
D-Bus/P2P: Treat PIN as string
authorReinette Chatre <reinette.chatre@intel.com>
Tue, 13 Sep 2011 16:27:29 +0000 (09:27 -0700)
committerJouni Malinen <j@w1.fi>
Wed, 21 Sep 2011 22:17:09 +0000 (01:17 +0300)
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 <reinette.chatre@intel.com>
Signed-off-by: Angie Chinchilla <angie.v.chinchilla@intel.com>
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new_handlers_p2p.c

index f3a74e8960ca59078afeff226a5d79bb5774d32d..39cf40155e9f4c18d5d475142dcc0cdb56a3ff75 100644 (file)
@@ -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
          }
        },
index f9c7cdcdbb0be980a944b73b9680e635be7a0484..0ab75539649223452a5143314e0cfcb1cdb15788 100644 (file)
@@ -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: