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>
{
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,
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;
}