From eaf30ea3ed36e4dce84fe154b2b458660a551737 Mon Sep 17 00:00:00 2001 From: Robert Stepanek Date: Wed, 5 Feb 2025 14:59:33 +0100 Subject: [PATCH] global.h: use function type taking any arguments for SASL callbacks 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 --- imap/global.h | 6 +----- imap/httpd.c | 6 +++--- imap/imapd.c | 8 ++++---- imap/lmtpd.c | 6 +++--- imap/lmtpengine.c | 2 +- imap/mupdate.c | 4 ++-- imap/nntpd.c | 6 +++--- imap/pop3d.c | 6 +++--- imap/saslclient.c | 8 ++++---- imap/sync_client.c | 4 ++-- imap/sync_server.c | 6 +++--- imtest/imtest.c | 6 +----- perl/sieve/lib/isieve.c | 12 ++---------- timsieved/timsieved.c | 6 +++--- 14 files changed, 35 insertions(+), 51 deletions(-) diff --git a/imap/global.h b/imap/global.h index 4900cd4bee..ab51f9e592 100644 --- a/imap/global.h +++ b/imap/global.h @@ -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, diff --git a/imap/httpd.c b/imap/httpd.c index 87ac451a46..e7536f7cfc 100644 --- a/imap/httpd.c +++ b/imap/httpd.c @@ -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 } }; diff --git a/imap/imapd.c b/imap/imapd.c index 1d075384fe..12e4210140 100644 --- a/imap/imapd.c +++ b/imap/imapd.c @@ -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 } }; diff --git a/imap/lmtpd.c b/imap/lmtpd.c index a2d601147a..697acf79a0 100644 --- a/imap/lmtpd.c +++ b/imap/lmtpd.c @@ -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 } }; diff --git a/imap/lmtpengine.c b/imap/lmtpengine.c index 950a514026..083fc04638 100644 --- a/imap/lmtpengine.c +++ b/imap/lmtpengine.c @@ -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 }, }; diff --git a/imap/mupdate.c b/imap/mupdate.c index 22fc4730c6..a7f43cffb4 100644 --- a/imap/mupdate.c +++ b/imap/mupdate.c @@ -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 } }; diff --git a/imap/nntpd.c b/imap/nntpd.c index eddc1f9872..b552a38628 100644 --- a/imap/nntpd.c +++ b/imap/nntpd.c @@ -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 } }; diff --git a/imap/pop3d.c b/imap/pop3d.c index 8c005bb60c..0dde3569af 100644 --- a/imap/pop3d.c +++ b/imap/pop3d.c @@ -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 } }; diff --git a/imap/saslclient.c b/imap/saslclient.c index 072db18ce8..cc15acddfb 100644 --- a/imap/saslclient.c +++ b/imap/saslclient.c @@ -119,7 +119,7 @@ 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++; } @@ -127,7 +127,7 @@ EXPORTED sasl_callback_t *mysasl_callbacks(const char *username, 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++; } @@ -135,7 +135,7 @@ EXPORTED sasl_callback_t *mysasl_callbacks(const char *username, 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++; } @@ -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++; } diff --git a/imap/sync_client.c b/imap/sync_client.c index 5d69f72c3b..b7cad0b371 100644 --- a/imap/sync_client.c +++ b/imap/sync_client.c @@ -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 } }; diff --git a/imap/sync_server.c b/imap/sync_server.c index ec5f2c8511..76ba52790a 100644 --- a/imap/sync_server.c +++ b/imap/sync_server.c @@ -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 } }; diff --git a/imtest/imtest.c b/imtest/imtest.c index 9c94e18e86..be75b9d740 100644 --- a/imtest/imtest.c +++ b/imtest/imtest.c @@ -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 } diff --git a/perl/sieve/lib/isieve.c b/perl/sieve/lib/isieve.c index 18c365395a..098b6695d9 100644 --- a/perl/sieve/lib/isieve.c +++ b/perl/sieve/lib/isieve.c @@ -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: diff --git a/timsieved/timsieved.c b/timsieved/timsieved.c index ce3796f2fd..2d20d32640 100644 --- a/timsieved/timsieved.c +++ b/timsieved/timsieved.c @@ -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 } };