1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

s4:kdc: Use smb_krb5_make_data()

smb_krb5_make_data() sets the magic field, which we were previously
ignoring. We should also not set krb5_data::length if krb5_data::data is
NULL.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2023-08-16 15:57:53 +12:00 committed by Andrew Bartlett
parent 6d2c7c45ca
commit 4b03aabe45

View File

@ -176,11 +176,12 @@ int mit_samba_generate_random_password(krb5_data *pwd)
{
TALLOC_CTX *tmp_ctx;
char *password;
char *data = NULL;
const unsigned length = 24;
if (pwd == NULL) {
return EINVAL;
}
pwd->length = 24;
tmp_ctx = talloc_named(NULL,
0,
@ -189,18 +190,20 @@ int mit_samba_generate_random_password(krb5_data *pwd)
return ENOMEM;
}
password = generate_random_password(tmp_ctx, pwd->length, pwd->length);
password = generate_random_password(tmp_ctx, length, length);
if (password == NULL) {
talloc_free(tmp_ctx);
return ENOMEM;
}
pwd->data = strdup(password);
data = strdup(password);
talloc_free(tmp_ctx);
if (pwd->data == NULL) {
if (data == NULL) {
return ENOMEM;
}
*pwd = smb_krb5_make_data(data, length);
return 0;
}