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. Samba BUG: https://bugzilla.samba.org/show_bug.cgi?id=15110 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
This commit is contained in:

committed by
Nico Williams

parent
16179383fb
commit
cfb32a638e
@@ -36,6 +36,8 @@
|
||||
#ifndef HEIMDAL_BASE_COMMON_PLUGIN_H
|
||||
#define HEIMDAL_BASE_COMMON_PLUGIN_H
|
||||
|
||||
#include <heimbase-svc.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef HEIM_CALLCONV
|
||||
# define HEIM_CALLCONV __stdcall
|
||||
@@ -69,9 +71,7 @@ typedef heim_get_instance_func_t krb5_get_instance_t;
|
||||
* All plugin function tables extend the following structure.
|
||||
*/
|
||||
struct heim_plugin_common_ftable_desc {
|
||||
int version;
|
||||
int (HEIM_LIB_CALL *init)(heim_pcontext, void **);
|
||||
void (HEIM_LIB_CALL *fini)(void *);
|
||||
HEIM_PLUGIN_FTABLE_COMMON_ELEMENTS(heim_pcontext);
|
||||
};
|
||||
typedef struct heim_plugin_common_ftable_desc heim_plugin_common_ftable;
|
||||
typedef struct heim_plugin_common_ftable_desc *heim_plugin_common_ftable_p;
|
||||
|
@@ -75,4 +75,9 @@
|
||||
heim_dict_t attributes; \
|
||||
int32_t error_code
|
||||
|
||||
#define HEIM_PLUGIN_FTABLE_COMMON_ELEMENTS(CONTEXT_TYPE) \
|
||||
int minor_version; \
|
||||
int (HEIM_LIB_CALL *init)(CONTEXT_TYPE, void **); \
|
||||
void (HEIM_LIB_CALL *fini)(void *)
|
||||
|
||||
#endif /* HEIMBASE_SVC_H */
|
||||
|
@@ -653,7 +653,7 @@ reduce_by_version(heim_object_t value, void *ctx, int *stop)
|
||||
struct iter_ctx *s = ctx;
|
||||
struct heim_plugin *pl = value;
|
||||
|
||||
if (pl->ftable && pl->ftable->version >= s->caller->min_version)
|
||||
if (pl->ftable && pl->ftable->minor_version >= s->caller->min_version)
|
||||
heim_array_append_value(s->result, pl);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user