summaryrefslogtreecommitdiff
path: root/third_party/heimdal/lib/hdb
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2022-10-22 10:11:53 +1300
committerAndrew Bartlett <abartlet@samba.org>2022-11-02 04:23:34 +0000
commit074e92849715ed3485703cfbba3771d405e4e78a (patch)
treec7cabefefa32f0524cd0721df10be0766595ed5e /third_party/heimdal/lib/hdb
parent6353f9e9c47d02dc0e18585bfaad48b2ce85441d (diff)
downloadsamba-074e92849715ed3485703cfbba3771d405e4e78a.tar.gz
third_party/heimdal: Introduce macro for common plugin structure elements
Heimdal's HDB plugin interface, and hence Samba's KDC that depends upon it, doesn't work on 32-bit builds due to structure fields being arranged in the wrong order. This problem presents itself in the form of segmentation faults on 32-bit systems, but goes unnoticed on 64-bit builds thanks to extra structure padding absorbing the errant fields. This commit reorders the HDB plugin structure fields to prevent crashes and introduces a common macro to ensure every plugin presents a consistent interface. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15110 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'third_party/heimdal/lib/hdb')
-rw-r--r--third_party/heimdal/lib/hdb/hdb-ldap.c3
-rw-r--r--third_party/heimdal/lib/hdb/hdb.c40
-rw-r--r--third_party/heimdal/lib/hdb/hdb.h4
-rw-r--r--third_party/heimdal/lib/hdb/test_namespace.c8
4 files changed, 27 insertions, 28 deletions
diff --git a/third_party/heimdal/lib/hdb/hdb-ldap.c b/third_party/heimdal/lib/hdb/hdb-ldap.c
index 6a2876c51d7..5cd097f5b6b 100644
--- a/third_party/heimdal/lib/hdb/hdb-ldap.c
+++ b/third_party/heimdal/lib/hdb/hdb-ldap.c
@@ -2097,9 +2097,9 @@ fini(void *ctx)
struct hdb_method hdb_ldap_interface = {
HDB_INTERFACE_VERSION,
- 0 /*is_file_based*/, 0 /*can_taste*/,
init,
fini,
+ 0 /*is_file_based*/, 0 /*can_taste*/,
"ldap",
hdb_ldap_create
};
@@ -2108,6 +2108,7 @@ struct hdb_method hdb_ldapi_interface = {
HDB_INTERFACE_VERSION,
init,
fini,
+ 0 /*is_file_based*/, 0 /*can_taste*/,
"ldapi",
hdb_ldapi_create
};
diff --git a/third_party/heimdal/lib/hdb/hdb.c b/third_party/heimdal/lib/hdb/hdb.c
index 56c403842e6..171ba9e3fd3 100644
--- a/third_party/heimdal/lib/hdb/hdb.c
+++ b/third_party/heimdal/lib/hdb/hdb.c
@@ -66,41 +66,41 @@ const int hdb_interface_version = HDB_INTERFACE_VERSION;
static struct hdb_method methods[] = {
/* "db:" should be db3 if we have db3, or db1 if we have db1 */
#if HAVE_DB3
- { HDB_INTERFACE_VERSION, 1 /*is_file_based*/, 1 /*can_taste*/, NULL, NULL,
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1 /*is_file_based*/, 1 /*can_taste*/,
"db:", hdb_db3_create},
#elif HAVE_DB1
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "db:", hdb_db1_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "db:", hdb_db1_create},
#endif
#if HAVE_DB1
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "db1:", hdb_db1_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "db1:", hdb_db1_create},
#endif
#if HAVE_DB3
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "db3:", hdb_db3_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "db3:", hdb_db3_create},
#endif
#if HAVE_DB1
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "mit-db:", hdb_mitdb_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "mit-db:", hdb_mitdb_create},
#endif
#if HAVE_LMDB
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "mdb:", hdb_mdb_create},
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "lmdb:", hdb_mdb_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "mdb:", hdb_mdb_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "lmdb:", hdb_mdb_create},
#endif
#if HAVE_NDBM
- { HDB_INTERFACE_VERSION, 1, 0, NULL, NULL, "ndbm:", hdb_ndbm_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 0, "ndbm:", hdb_ndbm_create},
#endif
#ifdef HAVE_SQLITE3
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "sqlite:", hdb_sqlite_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "sqlite:", hdb_sqlite_create},
#endif
/* The keytab interface can't use its hdb_open() method to "taste" a DB */
- { HDB_INTERFACE_VERSION, 1, 0, NULL, NULL, "keytab:", hdb_keytab_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 0, "keytab:", hdb_keytab_create},
/* The rest are not file-based */
#if defined(OPENLDAP) && !defined(OPENLDAP_MODULE)
- { HDB_INTERFACE_VERSION, 0, 0, NULL, NULL, "ldap:", hdb_ldap_create},
- { HDB_INTERFACE_VERSION, 0, 0, NULL, NULL, "ldapi:", hdb_ldapi_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 0, 0, "ldap:", hdb_ldap_create},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 0, 0, "ldapi:", hdb_ldapi_create},
#elif defined(OPENLDAP)
- { HDB_INTERFACE_VERSION, 0, 0, NULL, NULL, "ldap:", NULL},
- { HDB_INTERFACE_VERSION, 0, 0, NULL, NULL, "ldapi:", NULL},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 0, 0, "ldap:", NULL},
+ { HDB_INTERFACE_VERSION, NULL, NULL, 0, 0, "ldapi:", NULL},
#endif
- { 0, 0, 0, NULL, NULL, NULL, NULL}
+ { 0, NULL, NULL, 0, 0, NULL, NULL}
};
/**
@@ -494,19 +494,19 @@ hdb_init_db(krb5_context context, HDB *db)
*/
#if defined(HAVE_LMDB)
static struct hdb_method default_dbmethod =
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "", hdb_mdb_create };
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "", hdb_mdb_create };
#elif defined(HAVE_DB3)
static struct hdb_method default_dbmethod =
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "", hdb_db3_create };
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "", hdb_db3_create };
#elif defined(HAVE_DB1)
static struct hdb_method default_dbmethod =
- { HDB_INTERFACE_VERSION, 1, 1, NULL, NULL, "", hdb_db1_create };
+ { HDB_INTERFACE_VERSION, NULL, NULL, 1, 1, "", hdb_db1_create };
#elif defined(HAVE_NDBM)
static struct hdb_method default_dbmethod =
- { HDB_INTERFACE_VERSION, 0, 1, NULL, NULL, "", hdb_ndbm_create };
+ { HDB_INTERFACE_VERSION, NULL, NULL, 0, 1, "", hdb_ndbm_create };
#else
static struct hdb_method default_dbmethod =
- { 0, 0, 0, NULL, NULL, NULL, NULL};
+ { 0, NULL, NULL, 0, 0, NULL, NULL};
#endif
static int
diff --git a/third_party/heimdal/lib/hdb/hdb.h b/third_party/heimdal/lib/hdb/hdb.h
index 0f2c92151e5..2a3d1c4bb8c 100644
--- a/third_party/heimdal/lib/hdb/hdb.h
+++ b/third_party/heimdal/lib/hdb/hdb.h
@@ -307,11 +307,9 @@ typedef struct HDB {
#define HDB_INTERFACE_VERSION 11
struct hdb_method {
- int version;
+ HEIM_PLUGIN_FTABLE_COMMON_ELEMENTS(krb5_context);
unsigned int is_file_based:1;
unsigned int can_taste:1;
- krb5_error_code (*init)(krb5_context, void **);
- void (*fini)(void *);
const char *prefix;
krb5_error_code (*create)(krb5_context, HDB **, const char *filename);
};
diff --git a/third_party/heimdal/lib/hdb/test_namespace.c b/third_party/heimdal/lib/hdb/test_namespace.c
index a4c44ba190e..f9b4cdbdde8 100644
--- a/third_party/heimdal/lib/hdb/test_namespace.c
+++ b/third_party/heimdal/lib/hdb/test_namespace.c
@@ -243,17 +243,17 @@ struct hdb_method hdb_test =
#ifdef WIN32
/* Not c99 */
HDB_INTERFACE_VERSION,
- 1 /*is_file_based*/, 1 /*can_taste*/,
hdb_test_init,
hdb_test_fini,
+ 1 /*is_file_based*/, 1 /*can_taste*/,
"test",
hdb_test_create
#else
- .version = HDB_INTERFACE_VERSION,
- .is_file_based = 1,
- .can_taste = 1,
+ .minor_version = HDB_INTERFACE_VERSION,
.init = hdb_test_init,
.fini = hdb_test_fini,
+ .is_file_based = 1,
+ .can_taste = 1,
.prefix = "test",
.create = hdb_test_create
#endif