Skip to content

Commit

Permalink
global.h: use function type taking any arguments for SASL callbacks
Browse files Browse the repository at this point in the history
The SASL API defines callback functions to be of type

int (*proc)(void);

but then calls these functions with differing argument types.
This is not sane and won't be allowed starting from C23 onwards.
clang-19 now rejects the current way we set these callbacks.
Until the callback functions are declared sanely in the SASL API
we'll cast the callbacks to a function take any arguments.

Thanks to @ksmurchison
  • Loading branch information
rsto committed Feb 5, 2025
1 parent c86de78 commit eaf30ea
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 51 deletions.
6 changes: 1 addition & 5 deletions imap/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ extern int mysasl_config(void *context,
unsigned *len);
extern sasl_security_properties_t *mysasl_secprops(int flags);

#if GCC_VERSION >= 80000
typedef void mysasl_cb_ft; /* shut up GCC */
#else
typedef int (mysasl_cb_ft)(void);
#endif
#define SASL_CB_PROC_PTR (int (*)())

/* user canonification */
extern const char *canonify_userid(char *user, const char *loginid,
Expand Down
6 changes: 3 additions & 3 deletions imap/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ static int meth_propfind_root(struct transaction_t *txn, void *params);
static struct saslprops_t saslprops = SASLPROPS_INITIALIZER;

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mysasl_proxy_policy, (void*) &httpd_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mysasl_proxy_policy, (void*) &httpd_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
8 changes: 4 additions & 4 deletions imap/imapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,10 @@ static int imapd_sasl_log(void *context __attribute__((unused)),
}

static const struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &imapd_proxy_policy, (void*) &imapd_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &imapd_canon_user, (void*) &disable_referrals },
{ SASL_CB_LOG, (mysasl_cb_ft *) &imapd_sasl_log, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &imapd_proxy_policy, (void*) &imapd_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &imapd_canon_user, (void*) &disable_referrals },
{ SASL_CB_LOG, SASL_CB_PROC_PTR &imapd_sasl_log, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
6 changes: 3 additions & 3 deletions imap/lmtpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ static struct protocol_t lmtp_protocol =
};

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mysasl_proxy_policy, NULL },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mysasl_proxy_policy, NULL },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
2 changes: 1 addition & 1 deletion imap/lmtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ static int localauth_mechlist_override(
}

static struct sasl_callback localauth_override_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &localauth_mechlist_override, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &localauth_mechlist_override, NULL },
{ SASL_CB_LIST_END, NULL, NULL },
};

Expand Down
4 changes: 2 additions & 2 deletions imap/mupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ static int mupdate_proxy_policy(sasl_conn_t *conn,
}

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mupdate_proxy_policy, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mupdate_proxy_policy, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
6 changes: 3 additions & 3 deletions imap/nntpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ extern int saslserver(sasl_conn_t *conn, const char *mech,
static struct saslprops_t saslprops = SASLPROPS_INITIALIZER;

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mysasl_proxy_policy, (void*) &nntp_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mysasl_proxy_policy, (void*) &nntp_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
6 changes: 3 additions & 3 deletions imap/pop3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ static int popd_proxy_policy(sasl_conn_t *conn,
}

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &popd_proxy_policy, (void*) &popd_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &popd_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &popd_proxy_policy, (void*) &popd_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &popd_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
8 changes: 4 additions & 4 deletions imap/saslclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ EXPORTED sasl_callback_t *mysasl_callbacks(const char *username,
if (username) {
/* user callback */
ret[n].id = SASL_CB_USER;
ret[n].proc = (mysasl_cb_ft *) &mysasl_simple_cb;
ret[n].proc = SASL_CB_PROC_PTR &mysasl_simple_cb;
ret[n].context = (char *) username;
n++;
}

if (authname) {
/* authname */
ret[n].id = SASL_CB_AUTHNAME;
ret[n].proc = (mysasl_cb_ft *) &mysasl_simple_cb;
ret[n].proc = SASL_CB_PROC_PTR &mysasl_simple_cb;
ret[n].context = (char *) authname;
n++;
}

if (realm) {
/* realm */
ret[n].id = SASL_CB_GETREALM;
ret[n].proc = (mysasl_cb_ft *) &mysasl_getrealm_cb;
ret[n].proc = SASL_CB_PROC_PTR &mysasl_getrealm_cb;
ret[n].context = (char *) realm;
n++;
}
Expand All @@ -150,7 +150,7 @@ EXPORTED sasl_callback_t *mysasl_callbacks(const char *username,

/* password */
ret[n].id = SASL_CB_PASS;
ret[n].proc = (mysasl_cb_ft *) &mysasl_getsecret_cb;
ret[n].proc = SASL_CB_PROC_PTR &mysasl_getsecret_cb;
ret[n].context = secret;
n++;
}
Expand Down
4 changes: 2 additions & 2 deletions imap/sync_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ static int cb_allmbox(const mbentry_t *mbentry, void *rock)
/* ====================================================================== */

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
6 changes: 3 additions & 3 deletions imap/sync_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ static struct proxy_context sync_proxyctx = {
};

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mysasl_proxy_policy, (void*) &sync_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, NULL },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mysasl_proxy_policy, (void*) &sync_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down
6 changes: 1 addition & 5 deletions imtest/imtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ static sasl_callback_t callbacks[] = {
}, {
SASL_CB_PASS, NULL, NULL
}, {
#if GCC_VERSION >= 80000
SASL_CB_GETOPT, (void*)&mysasl_config, NULL
#else
SASL_CB_GETOPT, (int (*)(void))&mysasl_config, NULL
#endif
SASL_CB_GETOPT, (int (*)()) &mysasl_config, NULL
}, {
SASL_CB_LIST_END, NULL, NULL
}
Expand Down
12 changes: 2 additions & 10 deletions perl/sieve/lib/isieve.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,19 +565,11 @@ static int do_referral(isieve_t *obj, char *refer_to)

switch (callbacks[n].id) {
case SASL_CB_USER:
#if GCC_VERSION >= 80000
callbacks[n].proc = (void*)&refer_simple_cb;
#else
callbacks[n].proc = (int (*)(void))&refer_simple_cb;
#endif
callbacks[n].proc = (int (*)()) &refer_simple_cb;
callbacks[n].context = userid ? userid : authid;
break;
case SASL_CB_AUTHNAME:
#if GCC_VERSION >= 80000
callbacks[n].proc = (void*)&refer_simple_cb;
#else
callbacks[n].proc = (int (*)(void))&refer_simple_cb;
#endif
callbacks[n].proc = (int (*)()) &refer_simple_cb;
callbacks[n].context = authid;
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions timsieved/timsieved.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ EXPORTED void fatal(const char *s, int code)
}

static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, (mysasl_cb_ft *) &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, (mysasl_cb_ft *) &mysasl_proxy_policy, (void*) &sieved_proxyctx },
{ SASL_CB_CANON_USER, (mysasl_cb_ft *) &mysasl_canon_user, (void*) &sieved_domainfromip },
{ SASL_CB_GETOPT, SASL_CB_PROC_PTR &mysasl_config, NULL },
{ SASL_CB_PROXY_POLICY, SASL_CB_PROC_PTR &mysasl_proxy_policy, (void*) &sieved_proxyctx },
{ SASL_CB_CANON_USER, SASL_CB_PROC_PTR &mysasl_canon_user, (void*) &sieved_domainfromip },
{ SASL_CB_LIST_END, NULL, NULL }
};

Expand Down

0 comments on commit eaf30ea

Please sign in to comment.