From 3110744a6baff7a4a061d0264e329cfe4b170431 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 22 Mar 2012 15:01:35 +0100 Subject: [PATCH] Fix null-terminated XAuth passwords, as sent by Android 4 --- src/libcharon/plugins/xauth_eap/xauth_eap.c | 4 ++++ src/libcharon/plugins/xauth_generic/xauth_generic.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/libcharon/plugins/xauth_eap/xauth_eap.c b/src/libcharon/plugins/xauth_eap/xauth_eap.c index e590843444..7ccb802051 100644 --- a/src/libcharon/plugins/xauth_eap/xauth_eap.c +++ b/src/libcharon/plugins/xauth_eap/xauth_eap.c @@ -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"); diff --git a/src/libcharon/plugins/xauth_generic/xauth_generic.c b/src/libcharon/plugins/xauth_generic/xauth_generic.c index 907de4322a..f0e675ac0d 100644 --- a/src/libcharon/plugins/xauth_generic/xauth_generic.c +++ b/src/libcharon/plugins/xauth_generic/xauth_generic.c @@ -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);