Fix a segfault, the original principal is needed i the pac code.
goto cleanup;
}
- code = ks_unmarshal_hdb_entry(context, &hentry->entry, kentry);
+ code = ks_unmarshal_hdb_entry(context, hentry, kentry);
if (code != 0) {
goto cleanup;
}
if (principal_string) {
krb5_free_unparsed_name(context, principal_string);
}
- if (hentry) {
- KS_FREE_DB_ENTRY(ks, hentry);
+ if (code != 0) {
+ if (hentry) {
+ KS_FREE_DB_ENTRY(ks, hentry);
+ }
}
return code;
while (code == 0) {
krb5_db_entry kentry;
- code = ks_unmarshal_hdb_entry(context, &hentry->entry, &kentry);
+ code = ks_unmarshal_hdb_entry(context, hentry, &kentry);
if (code == 0) {
code = (*func)(func_arg, &kentry);
ks_free_krb5_db_entry(context, &kentry);
}
- KS_FREE_DB_ENTRY(ks, hentry);
-
if (code != 0) {
break;
}
/* NOTE: Relies on the fact that samba doesn't use the context
* for free_entry(), that's why we declare it (void *) */
-#define KS_FREE_DB_ENTRY(ks_ctx, hentry) hentry->free_entry(NULL, hentry);
+#define KS_FREE_DB_ENTRY(ks_ctx, hentry) (hentry)->free_entry(NULL, (hentry));
#include "kdb_samba_interface.h"
krb5_error_code
ks_unmarshal_hdb_entry(krb5_context context,
- const hdb_entry *hentry,
+ struct hdb_entry_ex *hentry,
krb5_db_entry *kentry);
/* from kdb_samba_policies.c */
krb5_tl_data *tl_data = NULL;
int i, j;
- assert(entry->e_data == NULL);
+ if (entry->e_data) {
+ KS_FREE_DB_ENTRY(ks, (struct hdb_entry_ex *)(entry->e_data));
+ }
krb5_free_principal(context, entry->princ);
krb5_error_code
ks_unmarshal_hdb_entry(krb5_context context,
- const hdb_entry *hentry,
+ struct hdb_entry_ex *hentry_ex,
krb5_db_entry *kentry)
{
+ const hdb_entry *hentry = &hentry_ex->entry;
krb5_error_code code;
unsigned int i;
kentry->n_key_data++;
}
+ kentry->e_data = (void *)hentry_ex;
+
cleanup:
if (code != 0) {
ks_free_krb5_db_entry(context, kentry);