Skip to content

Commit

Permalink
kadm5 ad backend wrong size memset
Browse files Browse the repository at this point in the history
Originally by Christos Zoulas.
  • Loading branch information
nicowilliams committed Mar 17, 2017
1 parent 2506aac commit bba35d0
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions lib/kadm5/ad.c
Expand Up @@ -1286,45 +1286,44 @@ kadm5_ad_randkey_principal(void *server_handle,
return ret;
}

krb5_data_zero (&result_code_string);
krb5_data_zero (&result_string);

ret = krb5_set_password_using_ccache (context->context,
context->ccache,
password,
principal,
&result_code,
&result_code_string,
&result_string);
krb5_data_zero(&result_code_string);
krb5_data_zero(&result_string);

ret = krb5_set_password_using_ccache(context->context,
context->ccache,
password,
principal,
&result_code,
&result_code_string,
&result_string);
krb5_data_free(&result_code_string);
krb5_data_free(&result_string);

krb5_data_free (&result_code_string);
krb5_data_free (&result_string);
if (ret)
goto out;

if (ret == 0) {
*keys = malloc(sizeof(**keys) * 1);
if (*keys == NULL) {
ret = ENOMEM;
goto out;
}
*n_keys = 1;

*keys = malloc(sizeof(**keys) * 1);
if (*keys == NULL) {
ret = ENOMEM;
goto out;
}
*n_keys = 1;

ret = krb5_string_to_key(context->context,
ENCTYPE_ARCFOUR_HMAC_MD5,
password,
principal,
&(*keys)[0]);
memset(password, 0, sizeof(password));
if (ret) {
free(*keys);
*keys = NULL;
*n_keys = 0;
goto out;
}
ret = krb5_string_to_key(context->context,
ENCTYPE_ARCFOUR_HMAC_MD5,
password,
principal,
&(*keys)[0]);
if (ret) {
free(*keys);
*keys = NULL;
*n_keys = 0;
goto out;
}

out:
memset(password, 0, plen);
free(password);
out:
return ret;
#else
*keys = NULL;
Expand Down

0 comments on commit bba35d0

Please sign in to comment.