Skip to content

Commit

Permalink
Fix memory leak in OTP kdcpreauth module
Browse files Browse the repository at this point in the history
In otp_edata(), free the generated nonce.

ticket: 9063 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next
  • Loading branch information
greghudson committed Jun 8, 2022
1 parent 8834150 commit 5ad465b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/preauth/otp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ otp_edata(krb5_context context, krb5_kdc_req *request,
krb5_pa_otp_challenge chl;
krb5_pa_data *pa = NULL;
krb5_error_code retval;
krb5_data *encoding;
krb5_data *encoding, nonce = empty_data();
char *config;

/* Determine if otp is enabled for the user. */
Expand Down Expand Up @@ -256,9 +256,10 @@ otp_edata(krb5_context context, krb5_kdc_req *request,
ti.iteration_count = -1;

/* Generate the nonce. */
retval = nonce_generate(context, armor_key->length, &chl.nonce);
retval = nonce_generate(context, armor_key->length, &nonce);
if (retval != 0)
goto out;
chl.nonce = nonce;

/* Build the output pa-data. */
retval = encode_krb5_pa_otp_challenge(&chl, &encoding);
Expand All @@ -275,6 +276,7 @@ otp_edata(krb5_context context, krb5_kdc_req *request,
free(encoding);

out:
krb5_free_data_contents(context, &nonce);
(*respond)(arg, retval, pa);
}

Expand Down

0 comments on commit 5ad465b

Please sign in to comment.