kadm5 ad backend wrong size memset

Originally by Christos Zoulas.
This commit is contained in:
Nicolas Williams
2017-01-31 11:33:13 -06:00
committed by Viktor Dukhovni
parent 936017e4d6
commit 369945f5bc

View File

@@ -1286,45 +1286,44 @@ kadm5_ad_randkey_principal(void *server_handle,
return ret; return ret;
} }
krb5_data_zero (&result_code_string); krb5_data_zero(&result_code_string);
krb5_data_zero (&result_string); krb5_data_zero(&result_string);
ret = krb5_set_password_using_ccache (context->context, ret = krb5_set_password_using_ccache(context->context,
context->ccache, context->ccache,
password, password,
principal, principal,
&result_code, &result_code,
&result_code_string, &result_code_string,
&result_string); &result_string);
krb5_data_free(&result_code_string);
krb5_data_free(&result_string);
krb5_data_free (&result_code_string); if (ret)
krb5_data_free (&result_string); goto out;
if (ret == 0) { *keys = malloc(sizeof(**keys) * 1);
if (*keys == NULL) {
*keys = malloc(sizeof(**keys) * 1); ret = ENOMEM;
if (*keys == NULL) { goto out;
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;
}
} }
*n_keys = 1;
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); memset(password, 0, plen);
free(password); free(password);
out:
return ret; return ret;
#else #else
*keys = NULL; *keys = NULL;