Fix null-terminated XAuth passwords, as sent by Android 4
authorMartin Willi <martin@revosec.ch>
Thu, 22 Mar 2012 14:01:35 +0000 (15:01 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 22 Mar 2012 14:09:25 +0000 (15:09 +0100)
src/libcharon/plugins/xauth_eap/xauth_eap.c
src/libcharon/plugins/xauth_generic/xauth_generic.c

index e590843..7ccb802 100644 (file)
@@ -217,6 +217,10 @@ METHOD(xauth_method_t, process, status_t,
                this->peer->destroy(this->peer);
                this->peer = id;
        }
+       if (pass.len && pass.ptr[pass.len - 1] == 0)
+       {       /* fix null-terminated passwords (Android etc.) */
+               pass.len -= 1;
+       }
 
        name = lib->settings->get_str(lib->settings,
                                                                  "charon.plugins.xauth-eap.backend", "radius");
index 907de43..f0e675a 100644 (file)
@@ -136,6 +136,10 @@ METHOD(xauth_method_t, process_server, status_t,
                this->peer->destroy(this->peer);
                this->peer = id;
        }
+       if (pass.len && pass.ptr[pass.len - 1] == 0)
+       {       /* fix null-terminated passwords (Android etc.) */
+               pass.len -= 1;
+       }
 
        enumerator = lib->credmgr->create_shared_enumerator(lib->credmgr,
                                                                                SHARED_EAP, this->server, this->peer);