]> git.ipfire.org Git - thirdparty/krb5.git/commit
Free cert info in pkinit_identity_initialize() 730/head
authorsashan <anedvedicky@gmail.com>
Tue, 20 Feb 2018 21:30:53 +0000 (22:30 +0100)
committerGreg Hudson <ghudson@mit.edu>
Mon, 26 Feb 2018 16:25:53 +0000 (11:25 -0500)
commite8909878b3ff95f4a9caf3a8cc80ce9d11a7d3e0
treec0037a4fba67462594589cf3e481ff81346ce5ae
parentcefc250efd71515dd665b606bcb993e617068758
Free cert info in pkinit_identity_initialize()

The pkinit_identity_crypto_context creds field contains a collection
of cert info deduced from configuration, and is used to select the
identity certificate on the client and the KDC.  Its lifetime is
managed separately from the context, by crypto_load_certs() and
crypto_free_cert_info().

Prior to commit 60426439f672fe273ceead17910f818da1954c5b, the lifetime
was managed purely within pkinit_identity_initialize().  When that
function now split into two phases, pkinit_identity_initialize() began
leaving the creds array around unnecessarily.  The client calling
function made its own call to free the creds array, but this was not
done by the KDC calling function.  The result was that the creds array
was overwritten in pkinit_identity_prompt(), leaking a small amount of
memory at KDC startup.  This leak is trivial, but adds noise to leak
detection tools.

Fix the leak by freeing the creds array in
pkinit_identity_initialize() before returning, and remove the
no-longer-necessary call in pkinit_client_prep_questions().  In the
longer term, it might be better to separate the creds array from
pkinit_identity_crypto_context and manage it using local variables
within pkinit_identity_initialize() and pkinit_identity_prompt().

[ghudson@mit.edu: rewrote commit message]
src/plugins/preauth/pkinit/pkinit_clnt.c
src/plugins/preauth/pkinit/pkinit_identity.c