From: Tobias Brunner Date: Fri, 19 Feb 2021 09:18:41 +0000 (+0100) Subject: xauth-generic: Pass XAuth message when getting password X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d765db1cf27e725991b4691feab5b3cd7257acad;p=thirdparty%2Fstrongswan.git xauth-generic: Pass XAuth message when getting password --- diff --git a/src/libcharon/plugins/xauth_generic/xauth_generic.c b/src/libcharon/plugins/xauth_generic/xauth_generic.c index 8f7c5fc2f5..e737c2652e 100644 --- a/src/libcharon/plugins/xauth_generic/xauth_generic.c +++ b/src/libcharon/plugins/xauth_generic/xauth_generic.c @@ -55,6 +55,7 @@ METHOD(xauth_method_t, process_peer, status_t, enumerator_t *enumerator; shared_key_t *shared; cp_payload_t *cp; + char *msg_str = NULL; chunk_t msg; enumerator = in->create_attribute_enumerator(in); @@ -64,7 +65,9 @@ METHOD(xauth_method_t, process_peer, status_t, { chunk_printable(attr->get_chunk(attr), &msg, '?'); DBG1(DBG_CFG, "XAuth message: %.*s", (int)msg.len, msg.ptr); + msg_str = strndup(msg.ptr, msg.len); free(msg.ptr); + break; } } enumerator->destroy(enumerator); @@ -89,7 +92,7 @@ METHOD(xauth_method_t, process_peer, status_t, case XAUTH_USER_PASSWORD: shared = lib->credmgr->get_shared(lib->credmgr, type, this->peer, this->server, - NULL); + msg_str); if (!shared) { DBG1(DBG_IKE, "no XAuth %s found for '%Y' - '%Y'", @@ -97,6 +100,7 @@ METHOD(xauth_method_t, process_peer, status_t, this->peer, this->server); enumerator->destroy(enumerator); cp->destroy(cp); + free(msg_str); return FAILED; } cp->add_attribute(cp, configuration_attribute_create_chunk( @@ -109,6 +113,7 @@ METHOD(xauth_method_t, process_peer, status_t, } } enumerator->destroy(enumerator); + free(msg_str); *out = cp; return NEED_MORE;