From ac84d4f20737b1841eb117ea8f6db20492ed29d4 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sat, 11 Sep 2021 07:53:30 +0200 Subject: [PATCH] Const const const... modules.c and elsewhere. --- include/h.h | 20 +++++------ include/modules.h | 58 +++++++++++++++---------------- src/api-efunctions.c | 10 +++--- src/api-moddata.c | 16 ++++----- src/auth.c | 2 +- src/conf.c | 2 +- src/dns.c | 16 ++++----- src/modules.c | 57 ++++++++++++++++-------------- src/modules/antirandom.c | 2 +- src/modules/authprompt.c | 2 +- src/modules/cap.c | 2 +- src/modules/certfp.c | 12 +++---- src/modules/chanmodes/delayjoin.c | 8 ++--- src/modules/extbans/certfp.c | 4 +-- src/modules/geoip_base.c | 8 ++--- src/modules/history_backend_mem.c | 2 +- src/modules/link-security.c | 27 ++++++-------- src/modules/md.c | 40 ++++++++++----------- src/modules/metadata.c | 4 +-- src/modules/plaintext-policy.c | 2 +- src/modules/reputation.c | 8 ++--- src/modules/sasl.c | 14 ++++---- src/modules/server.c | 4 +-- src/modules/sts.c | 2 +- src/modules/tkl.c | 2 +- src/modules/tls_cipher.c | 10 +++--- src/modules/webirc.c | 8 ++--- src/modules/whox.c | 8 ++--- src/send.c | 2 +- src/tls.c | 4 +-- src/user.c | 3 +- 31 files changed, 176 insertions(+), 183 deletions(-) diff --git a/include/h.h b/include/h.h index 4a2a2560c..b3fb7c798 100644 --- a/include/h.h +++ b/include/h.h @@ -261,6 +261,7 @@ extern void sendto_snomask_global(int snomask, FORMAT_STRING(const char *pattern extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3))); extern void sendnumeric(Client *to, int numeric, ...); extern void sendnumericfmt(Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,3,4))); +extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3))); extern void sendto_server(Client *one, unsigned long caps, unsigned long nocaps, MessageTag *mtags, FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 5, 6))); extern MODVAR int writecalls, writeb[]; @@ -731,10 +732,10 @@ extern MODVAR void (*broadcast_md_client)(ModDataInfo *mdi, Client *acptr, ModDa extern MODVAR void (*broadcast_md_channel)(ModDataInfo *mdi, Channel *channel, ModData *md); extern MODVAR void (*broadcast_md_member)(ModDataInfo *mdi, Channel *channel, Member *m, ModData *md); extern MODVAR void (*broadcast_md_membership)(ModDataInfo *mdi, Client *acptr, Membership *m, ModData *md); -extern MODVAR void (*broadcast_md_client_cmd)(Client *except, Client *sender, Client *acptr, char *varname, char *value); -extern MODVAR void (*broadcast_md_channel_cmd)(Client *except, Client *sender, Channel *channel, char *varname, char *value); -extern MODVAR void (*broadcast_md_member_cmd)(Client *except, Client *sender, Channel *channel, Client *acptr, char *varname, char *value); -extern MODVAR void (*broadcast_md_membership_cmd)(Client *except, Client *sender, Client *acptr, Channel *channel, char *varname, char *value); +extern MODVAR void (*broadcast_md_client_cmd)(Client *except, Client *sender, Client *acptr, const char *varname, const char *value); +extern MODVAR void (*broadcast_md_channel_cmd)(Client *except, Client *sender, Channel *channel, const char *varname, const char *value); +extern MODVAR void (*broadcast_md_member_cmd)(Client *except, Client *sender, Channel *channel, Client *acptr, const char *varname, const char *value); +extern MODVAR void (*broadcast_md_membership_cmd)(Client *except, Client *sender, Client *acptr, Channel *channel, const char *varname, const char *value); extern MODVAR void (*moddata_add_s2s_mtags)(Client *client, MessageTag **mtags); extern MODVAR void (*moddata_extract_s2s_mtags)(Client *client, MessageTag *mtags); extern MODVAR void (*send_moddata_client)(Client *srv, Client *acptr); @@ -757,7 +758,7 @@ extern MODVAR void (*parse_message_tags)(Client *cptr, char **str, MessageTag ** extern MODVAR char *(*mtags_to_string)(MessageTag *m, Client *acptr); extern MODVAR int (*can_send_to_channel)(Client *cptr, Channel *channel, const char **msgtext, const char **errmsg, int notice); extern MODVAR void (*broadcast_md_globalvar)(ModDataInfo *mdi, ModData *md); -extern MODVAR void (*broadcast_md_globalvar_cmd)(Client *except, Client *sender, char *varname, char *value); +extern MODVAR void (*broadcast_md_globalvar_cmd)(Client *except, Client *sender, const char *varname, const char *value); extern MODVAR int (*tkl_ip_hash)(char *ip); extern MODVAR int (*tkl_ip_hash_type)(int type); extern MODVAR int (*find_tkl_exception)(int ban_type, Client *cptr); @@ -790,7 +791,7 @@ extern char *ssl_error_str(int err, int my_errno); extern void unreal_tls_client_handshake(int, int, void *); extern void SSL_set_nonblocking(SSL *s); extern SSL_CTX *init_ctx(TLSOptions *tlsoptions, int server); -extern char *tls_get_cipher(Client *client); +extern const char *tls_get_cipher(Client *client); extern TLSOptions *get_tls_options_for_client(Client *acptr); extern int outdated_tls_client(Client *acptr); extern char *outdated_tls_client_build_string(char *pattern, Client *acptr); @@ -828,12 +829,11 @@ extern MODVAR TKL *tklines[TKLISTLEN]; extern MODVAR TKL *tklines_ip_hash[TKLIPHASHLEN1][TKLIPHASHLEN2]; extern const char *cmdname_by_spamftarget(int target); extern void unrealdns_delreq_bycptr(Client *cptr); -extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3))); -extern void unrealdns_gethostbyname_link(char *name, ConfigItem_link *conf, int ipv4_only); +extern void unrealdns_gethostbyname_link(const char *name, ConfigItem_link *conf, int ipv4_only); extern void unrealdns_delasyncconnects(void); extern int is_autojoin_chan(const char *chname); extern void unreal_free_hostent(struct hostent *he); -extern struct hostent *unreal_create_hostent(char *name, char *ip); +extern struct hostent *unreal_create_hostent(const char *name, const char *ip); extern char *unreal_time_sync_error(void); extern int unreal_time_synch(int timeout); extern const char *getcloak(Client *client); @@ -941,7 +941,7 @@ extern void sendbufto_one(Client *to, char *msg, unsigned int quick); extern MODVAR int current_serial; extern char *spki_fingerprint(Client *acptr); extern char *spki_fingerprint_ex(X509 *x509_cert); -extern int is_module_loaded(char *name); +extern int is_module_loaded(const char *name); extern void close_std_descriptors(void); extern void banned_client(Client *acptr, const char *bantype, const char *reason, int global, int noexit); extern char *mystpcpy(char *dst, const char *src); diff --git a/include/modules.h b/include/modules.h index 693091009..965854797 100644 --- a/include/modules.h +++ b/include/modules.h @@ -153,8 +153,8 @@ struct ModDataInfo { int slot; /**< Assigned slot */ char unloaded; /**< Module being unloaded? */ void (*free)(ModData *m); /**< Function will be called when the data needs to be freed (may be NULL if not using dynamic storage) */ - char *(*serialize)(ModData *m); /**< Function which converts the data to a string. May return NULL if 'm' contains no data (since for example m->ptr may be NULL). */ - void (*unserialize)(char *str, ModData *m); /**< Function which converts the string back to data */ + const char *(*serialize)(ModData *m); /**< Function which converts the data to a string. May return NULL if 'm' contains no data (since for example m->ptr may be NULL). */ + void (*unserialize)(const char *str, ModData *m); /**< Function which converts the string back to data */ ModDataSync sync; /**< Send in netsynch (when servers connect) */ int remote_write; /**< Allow remote servers to set/unset this moddata, even if it they target one of our own clients */ int self_write; /**< Allow remote servers to set/unset moddata of their own server object (irc1.example.net writing the MD object of irc1.example.net) */ @@ -457,8 +457,8 @@ struct ClientCapability { char *name; /**< The name of the CAP */ long cap; /**< The acptr->user->proto we should set (if any, can be 0, like for sts) */ int flags; /**< A flag from CLICAP_FLAGS_* */ - int (*visible)(Client *); /**< Should the capability be visible? Note: parameter may be NULL. [optional] */ - char *(*parameter)(Client *); /**< CAP parameters. Note: parameter may be NULL. [optional] */ + int (*visible)(Client *); /**< Should the capability be visible? Note: parameter may be NULL. [optional] */ + const char *(*parameter)(Client *); /**< CAP parameters. Note: parameter may be NULL. [optional] */ MessageTagHandler *mtag_handler; /**< For reverse dependency */ Module *owner; /**< Module introducing this CAP. */ char unloaded; /**< Internal flag to indicate module is being unloaded */ @@ -468,7 +468,7 @@ typedef struct { char *name; int flags; int (*visible)(Client *); - char *(*parameter)(Client *); + const char *(*parameter)(Client *); } ClientCapabilityInfo; /** @defgroup MessagetagAPI Message tag API @@ -749,21 +749,19 @@ extern void EventStatus(Client *client); extern void SetupEvents(void); -extern void Module_Init(void); -extern char *Module_Create(char *path); -extern const char *Module_TransformPath(const char *path_); -extern void Init_all_testing_modules(void); -extern void Unload_all_loaded_modules(void); -extern void Unload_all_testing_modules(void); -extern int Module_Unload(char *name); -extern vFP Module_Sym(char *name); -extern vFP Module_SymX(char *name, Module **mptr); -extern int Module_free(Module *mod); - +extern void Module_Init(void); +extern const char *Module_Create(const char *path); +extern const char *Module_TransformPath(const char *path_); +extern void Init_all_testing_modules(void); +extern void Unload_all_loaded_modules(void); +extern void Unload_all_testing_modules(void); +extern int Module_Unload(const char *name); +extern vFP Module_Sym(const char *name); +extern vFP Module_SymX(const char *name, Module **mptr); +extern int Module_free(Module *mod); #ifdef __OpenBSD__ -extern void *obsd_dlsym(void *handle, char *symbol); +extern void *obsd_dlsym(void *handle, const char *symbol); #endif - #ifdef _WIN32 extern const char *our_dlerror(void); #endif @@ -882,26 +880,26 @@ extern void moddata_free_local_client(Client *acptr); extern void moddata_free_channel(Channel *channel); extern void moddata_free_member(Member *m); extern void moddata_free_membership(Membership *m); -extern ModDataInfo *findmoddata_byname(char *name, ModDataType type); -extern int moddata_client_set(Client *acptr, char *varname, char *value); -extern char *moddata_client_get(Client *acptr, char *varname); -extern ModData *moddata_client_get_raw(Client *client, char *varname); -extern int moddata_local_client_set(Client *acptr, char *varname, char *value); -extern char *moddata_local_client_get(Client *acptr, char *varname); +extern ModDataInfo *findmoddata_byname(const char *name, ModDataType type); +extern int moddata_client_set(Client *acptr, const char *varname, const char *value); +extern const char *moddata_client_get(Client *acptr, const char *varname); +extern ModData *moddata_client_get_raw(Client *client, const char *varname); +extern int moddata_local_client_set(Client *acptr, const char *varname, const char *value); +extern const char *moddata_local_client_get(Client *acptr, const char *varname); -extern int LoadPersistentPointerX(ModuleInfo *modinfo, char *varshortname, void **var, void (*free_variable)(ModData *m)); +extern int LoadPersistentPointerX(ModuleInfo *modinfo, const char *varshortname, void **var, void (*free_variable)(ModData *m)); #define LoadPersistentPointer(modinfo, var, free_variable) LoadPersistentPointerX(modinfo, #var, (void **)&var, free_variable) -extern void SavePersistentPointerX(ModuleInfo *modinfo, char *varshortname, void *var); +extern void SavePersistentPointerX(ModuleInfo *modinfo, const char *varshortname, void *var); #define SavePersistentPointer(modinfo, var) SavePersistentPointerX(modinfo, #var, var) -extern int LoadPersistentIntX(ModuleInfo *modinfo, char *varshortname, int *var); +extern int LoadPersistentIntX(ModuleInfo *modinfo, const char *varshortname, int *var); #define LoadPersistentInt(modinfo, var) LoadPersistentIntX(modinfo, #var, &var) -extern void SavePersistentIntX(ModuleInfo *modinfo, char *varshortname, int var); +extern void SavePersistentIntX(ModuleInfo *modinfo, const char *varshortname, int var); #define SavePersistentInt(modinfo, var) SavePersistentIntX(modinfo, #var, var) -extern int LoadPersistentLongX(ModuleInfo *modinfo, char *varshortname, long *var); +extern int LoadPersistentLongX(ModuleInfo *modinfo, const char *varshortname, long *var); #define LoadPersistentLong(modinfo, var) LoadPersistentLongX(modinfo, #var, &var) -extern void SavePersistentLongX(ModuleInfo *modinfo, char *varshortname, long var); +extern void SavePersistentLongX(ModuleInfo *modinfo, const char *varshortname, long var); #define SavePersistentLong(modinfo, var) SavePersistentLongX(modinfo, #var, var) /** Hooks trigger on "events", such as a new user connecting or joining a channel, diff --git a/src/api-efunctions.c b/src/api-efunctions.c index 06a49e0ac..678f16d6b 100644 --- a/src/api-efunctions.c +++ b/src/api-efunctions.c @@ -85,10 +85,10 @@ void (*broadcast_md_member)(ModDataInfo *mdi, Channel *channel, Member *m, ModDa void (*broadcast_md_membership)(ModDataInfo *mdi, Client *client, Membership *m, ModData *md); int (*check_banned)(Client *client, int exitflags); int (*check_deny_version)(Client *client, char *software, int protocol, char *flags); -void (*broadcast_md_client_cmd)(Client *except, Client *sender, Client *acptr, char *varname, char *value); -void (*broadcast_md_channel_cmd)(Client *except, Client *sender, Channel *channel, char *varname, char *value); -void (*broadcast_md_member_cmd)(Client *except, Client *sender, Channel *channel, Client *acptr, char *varname, char *value); -void (*broadcast_md_membership_cmd)(Client *except, Client *sender, Client *acptr, Channel *channel, char *varname, char *value); +void (*broadcast_md_client_cmd)(Client *except, Client *sender, Client *acptr, const char *varname, const char *value); +void (*broadcast_md_channel_cmd)(Client *except, Client *sender, Channel *channel, const char *varname, const char *value); +void (*broadcast_md_member_cmd)(Client *except, Client *sender, Channel *channel, Client *acptr, const char *varname, const char *value); +void (*broadcast_md_membership_cmd)(Client *except, Client *sender, Client *acptr, Channel *channel, const char *varname, const char *value); void (*moddata_add_s2s_mtags)(Client *client, MessageTag **mtags); void (*moddata_extract_s2s_mtags)(Client *client, MessageTag *mtags); void (*send_moddata_client)(Client *srv, Client *client); @@ -108,7 +108,7 @@ void (*parse_message_tags)(Client *client, char **str, MessageTag **mtag_list); char *(*mtags_to_string)(MessageTag *m, Client *client); int (*can_send_to_channel)(Client *client, Channel *channel, const char **msgtext, const char **errmsg, int notice); void (*broadcast_md_globalvar)(ModDataInfo *mdi, ModData *md); -void (*broadcast_md_globalvar_cmd)(Client *except, Client *sender, char *varname, char *value); +void (*broadcast_md_globalvar_cmd)(Client *except, Client *sender, const char *varname, const char *value); int (*tkl_ip_hash)(char *ip); int (*tkl_ip_hash_type)(int type); void (*sendnotice_tkl_del)(char *removed_by, TKL *tkl); diff --git a/src/api-moddata.c b/src/api-moddata.c index 70a1ef226..1dd503538 100644 --- a/src/api-moddata.c +++ b/src/api-moddata.c @@ -294,7 +294,7 @@ ModDataInfo *md, *md_next; } } -ModDataInfo *findmoddata_byname(char *name, ModDataType type) +ModDataInfo *findmoddata_byname(const char *name, ModDataType type) { ModDataInfo *md; @@ -317,7 +317,7 @@ int module_has_moddata(Module *mod) } /** Set ModData for client (via variable name, string value) */ -int moddata_client_set(Client *client, char *varname, char *value) +int moddata_client_set(Client *client, const char *varname, const char *value) { ModDataInfo *md; @@ -348,7 +348,7 @@ int moddata_client_set(Client *client, char *varname, char *value) } /** Get ModData for client (via variable name) */ -char *moddata_client_get(Client *client, char *varname) +const char *moddata_client_get(Client *client, const char *varname) { ModDataInfo *md; @@ -361,7 +361,7 @@ char *moddata_client_get(Client *client, char *varname) } /** Get ModData for client (via variable name) */ -ModData *moddata_client_get_raw(Client *client, char *varname) +ModData *moddata_client_get_raw(Client *client, const char *varname) { ModDataInfo *md; @@ -374,7 +374,7 @@ ModData *moddata_client_get_raw(Client *client, char *varname) } /** Set ModData for LocalClient (via variable name, string value) */ -int moddata_local_client_set(Client *client, char *varname, char *value) +int moddata_local_client_set(Client *client, const char *varname, const char *value) { ModDataInfo *md; @@ -408,7 +408,7 @@ int moddata_local_client_set(Client *client, char *varname, char *value) } /** Get ModData for LocalClient (via variable name) */ -char *moddata_local_client_get(Client *client, char *varname) +const char *moddata_local_client_get(Client *client, const char *varname) { ModDataInfo *md; @@ -424,7 +424,7 @@ char *moddata_local_client_get(Client *client, char *varname) } /** Set local variable moddata (via variable name, string value) */ -int moddata_local_variable_set(char *varname, char *value) +int moddata_local_variable_set(const char *varname, const char *value) { ModDataInfo *md; @@ -449,7 +449,7 @@ int moddata_local_variable_set(char *varname, char *value) } /** Set global variable moddata (via variable name, string value) */ -int moddata_global_variable_set(char *varname, char *value) +int moddata_global_variable_set(const char *varname, const char *value) { ModDataInfo *md; diff --git a/src/auth.c b/src/auth.c index b80aee179..857a7290d 100644 --- a/src/auth.c +++ b/src/auth.c @@ -362,7 +362,7 @@ static int authcheck_tls_clientcert_fingerprint(Client *client, AuthConfig *as, { int i, k; char hexcolon[EVP_MAX_MD_SIZE * 3 + 1]; - char *fp; + const char *fp; if (!client->local->ssl) return 0; diff --git a/src/conf.c b/src/conf.c index df447db12..dd44122db 100644 --- a/src/conf.c +++ b/src/conf.c @@ -9203,7 +9203,7 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce) int _conf_loadmodule(ConfigFile *conf, ConfigEntry *ce) { - char *ret; + const char *ret; if (!ce->value) { config_status("%s:%i: loadmodule without filename", diff --git a/src/dns.c b/src/dns.c index 960c68e35..f151a8d76 100644 --- a/src/dns.c +++ b/src/dns.c @@ -40,9 +40,9 @@ void unrealdns_cb_nametoip_verify(void *arg, int status, int timeouts, struct ho void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct hostent *he); void unrealdns_delasyncconnects(void); static uint64_t unrealdns_hash_ip(const char *ip); -static void unrealdns_addtocache(char *name, char *ip); -static char *unrealdns_findcache_ip(char *ip); -struct hostent *unreal_create_hostent(char *name, char *ip); +static void unrealdns_addtocache(const char *name, const char *ip); +static const char *unrealdns_findcache_ip(const char *ip); +struct hostent *unreal_create_hostent(const char *name, const char *ip); static void unrealdns_freeandremovereq(DNSReq *r); void unrealdns_removecacherecord(DNSCache *c); @@ -201,7 +201,7 @@ void unrealdns_addreqtolist(DNSReq *r) struct hostent *unrealdns_doclient(Client *client) { DNSReq *r; - char *cache_name; + const char *cache_name; cache_name = unrealdns_findcache_ip(client->ip); if (cache_name) @@ -232,7 +232,7 @@ struct hostent *unrealdns_doclient(Client *client) /** Resolve a name to an IP, for a link block. */ -void unrealdns_gethostbyname_link(char *name, ConfigItem_link *conf, int ipv4_only) +void unrealdns_gethostbyname_link(const char *name, ConfigItem_link *conf, int ipv4_only) { DNSReq *r; @@ -412,7 +412,7 @@ static uint64_t unrealdns_hash_ip(const char *ip) return siphash(ip, siphashkey_dns_ip) % DNS_HASH_SIZE; } -static void unrealdns_addtocache(char *name, char *ip) +static void unrealdns_addtocache(const char *name, const char *ip) { unsigned int hashv; DNSCache *c; @@ -464,7 +464,7 @@ static void unrealdns_addtocache(char *name, char *ip) /** Search the cache for a confirmed ip->name and name->ip match, by address. * @returns The resolved hostname, or NULL if not found in cache. */ -static char *unrealdns_findcache_ip(char *ip) +static const char *unrealdns_findcache_ip(const char *ip) { unsigned int hashv; DNSCache *c; @@ -542,7 +542,7 @@ DNSCache *c, *next; } } -struct hostent *unreal_create_hostent(char *name, char *ip) +struct hostent *unreal_create_hostent(const char *name, const char *ip) { struct hostent *he; diff --git a/src/modules.c b/src/modules.c index 7fb78c76e..482585a0c 100644 --- a/src/modules.c +++ b/src/modules.c @@ -52,7 +52,7 @@ Module *Module_make(ModuleHeader *header, #ifdef UNDERSCORE /* dlsym for OpenBSD */ -void *obsd_dlsym(void *handle, char *symbol) +void *obsd_dlsym(void *handle, const char *symbol) { size_t buflen = strlen(symbol) + 2; char *obsdsymbol = safe_alloc(buflen); @@ -131,7 +131,7 @@ void DeleteTempModules(void) #endif } -Module *Module_Find(char *name) +Module *Module_Find(const char *name) { Module *p; @@ -149,7 +149,7 @@ Module *Module_Find(char *name) } -int parse_modsys_version(char *version) +int parse_modsys_version(const char *version) { if (!strcmp(version, "unrealircd-6")) return 0x600000; @@ -158,7 +158,7 @@ int parse_modsys_version(char *version) void make_compiler_string(char *buf, size_t buflen, unsigned int ver) { -unsigned int maj, min, plevel; + unsigned int maj, min, plevel; if (ver == 0) { @@ -226,7 +226,7 @@ const char *Module_GetRelPath(const char *fullpath) /** Validate a modules' ModuleHeader. * @returns Error message is returned, or NULL if everything is OK. */ -static char *validate_mod_header(const char *relpath, ModuleHeader *mod_header) +static const char *validate_mod_header(const char *relpath, ModuleHeader *mod_header) { char *p; static char buf[256]; @@ -278,7 +278,7 @@ int module_already_in_testing(const char *relpath) /* * Returns an error if insucessful .. yes NULL is OK! */ -char *Module_Create(char *path_) +const char *Module_Create(const char *path_) { #ifdef _WIN32 HMODULE Mod; @@ -295,7 +295,7 @@ char *Module_Create(char *path_) const char *path, *relpath, *tmppath; ModuleHeader *mod_header = NULL; int ret = 0; - char *reterr; + const char *reterr; Module *mod = NULL, **Mod_Handle = NULL; char *expectedmodversion = our_mod_version; unsigned int expectedcompilerversion = our_compiler_version; @@ -447,7 +447,7 @@ char *Module_Create(char *path_) else { /* Return the error .. */ - return ((char *)irc_dlerror()); + return irc_dlerror(); } } @@ -695,7 +695,7 @@ int Module_free(Module *mod) * 1 Module unloaded * 2 Module wishes delayed unloading, has placed event */ -int Module_Unload(char *name) +int Module_Unload(const char *name) { Module *m; int (*Mod_Unload)(); @@ -886,7 +886,7 @@ CMD_FUNC(cmd_module) sendtxtnumeric(client, "Override: %s", tmp); } -Hooktype *HooktypeFind(char *string) { +Hooktype *HooktypeFind(const char *string) { Hooktype *hooktype; for (hooktype = Hooktypes; hooktype->string ;hooktype++) { if (!strcasecmp(hooktype->string, string)) @@ -1323,7 +1323,7 @@ const char *our_dlerror(void) * @note The name is checked against the module name, * this can be a problem if two modules have the same name. */ -int is_module_loaded(char *name) +int is_module_loaded(const char *name) { Module *mi; for (mi = Modules; mi; mi = mi->next) @@ -1337,17 +1337,17 @@ int is_module_loaded(char *name) return 0; } -static char *mod_var_name(ModuleInfo *modinfo, char *varshortname) +static const char *mod_var_name(ModuleInfo *modinfo, const char *varshortname) { static char fullname[512]; snprintf(fullname, sizeof(fullname), "%s:%s", modinfo->handle->header->name, varshortname); return fullname; } -int LoadPersistentPointerX(ModuleInfo *modinfo, char *varshortname, void **var, void (*free_variable)(ModData *m)) +int LoadPersistentPointerX(ModuleInfo *modinfo, const char *varshortname, void **var, void (*free_variable)(ModData *m)) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); if (m) @@ -1358,27 +1358,28 @@ int LoadPersistentPointerX(ModuleInfo *modinfo, char *varshortname, void **var, ModDataInfo mreq; memset(&mreq, 0, sizeof(mreq)); mreq.type = MODDATATYPE_LOCAL_VARIABLE; - mreq.name = fullname; + mreq.name = strdup(fullname); mreq.free = free_variable; m = ModDataAdd(modinfo->handle, mreq); moddata_local_variable(m).ptr = NULL; + safe_free(mreq.name); return 0; } } -void SavePersistentPointerX(ModuleInfo *modinfo, char *varshortname, void *var) +void SavePersistentPointerX(ModuleInfo *modinfo, const char *varshortname, void *var) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); moddata_local_variable(m).ptr = var; } -int LoadPersistentIntX(ModuleInfo *modinfo, char *varshortname, int *var) +int LoadPersistentIntX(ModuleInfo *modinfo, const char *varshortname, int *var) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); if (m) @@ -1389,27 +1390,28 @@ int LoadPersistentIntX(ModuleInfo *modinfo, char *varshortname, int *var) ModDataInfo mreq; memset(&mreq, 0, sizeof(mreq)); mreq.type = MODDATATYPE_LOCAL_VARIABLE; - mreq.name = fullname; + mreq.name = strdup(fullname); mreq.free = NULL; m = ModDataAdd(modinfo->handle, mreq); moddata_local_variable(m).i = 0; + safe_free(mreq.name); return 0; } } -void SavePersistentIntX(ModuleInfo *modinfo, char *varshortname, int var) +void SavePersistentIntX(ModuleInfo *modinfo, const char *varshortname, int var) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); moddata_local_variable(m).i = var; } -int LoadPersistentLongX(ModuleInfo *modinfo, char *varshortname, long *var) +int LoadPersistentLongX(ModuleInfo *modinfo, const char *varshortname, long *var) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); if (m) @@ -1420,18 +1422,19 @@ int LoadPersistentLongX(ModuleInfo *modinfo, char *varshortname, long *var) ModDataInfo mreq; memset(&mreq, 0, sizeof(mreq)); mreq.type = MODDATATYPE_LOCAL_VARIABLE; - mreq.name = fullname; + mreq.name = strdup(fullname); mreq.free = NULL; m = ModDataAdd(modinfo->handle, mreq); moddata_local_variable(m).l = 0; + safe_free(mreq.name); return 0; } } -void SavePersistentLongX(ModuleInfo *modinfo, char *varshortname, long var) +void SavePersistentLongX(ModuleInfo *modinfo, const char *varshortname, long var) { ModDataInfo *m; - char *fullname = mod_var_name(modinfo, varshortname); + const char *fullname = mod_var_name(modinfo, varshortname); m = findmoddata_byname(fullname, MODDATATYPE_LOCAL_VARIABLE); moddata_local_variable(m).l = var; diff --git a/src/modules/antirandom.c b/src/modules/antirandom.c index 878466e53..bdf664276 100644 --- a/src/modules/antirandom.c +++ b/src/modules/antirandom.c @@ -897,7 +897,7 @@ static int is_exempt(Client *client) /* WEBIRC gateway and exempt? */ if (cfg.except_webirc) { - char *val = moddata_client_get(client, "webirc"); + const char *val = moddata_client_get(client, "webirc"); if (val && (atoi(val)>0)) return 1; } diff --git a/src/modules/authprompt.c b/src/modules/authprompt.c index a38a961e2..a2c0a4875 100644 --- a/src/modules/authprompt.c +++ b/src/modules/authprompt.c @@ -295,7 +295,7 @@ void send_first_auth(Client *client) { Client *sasl_server; char *addr = BadPtr(client->ip) ? "0" : client->ip; - char *certfp = moddata_client_get(client, "certfp"); + const char *certfp = moddata_client_get(client, "certfp"); sasl_server = find_client(SASL_SERVER, NULL); if (!sasl_server) { diff --git a/src/modules/cap.c b/src/modules/cap.c index 1f4504441..08ffe5e31 100644 --- a/src/modules/cap.c +++ b/src/modules/cap.c @@ -160,7 +160,7 @@ static void clicap_generate(Client *client, const char *subcmd, int flags) for (cap = clicaps; cap; cap = cap->next) { char name[256]; - char *param; + const char *param; if (cap->visible && !cap->visible(client)) continue; /* hidden */ diff --git a/src/modules/certfp.c b/src/modules/certfp.c index 7bfafe7e3..2daa41bbb 100644 --- a/src/modules/certfp.c +++ b/src/modules/certfp.c @@ -22,8 +22,8 @@ ModuleHeader MOD_HEADER /* Forward declarations */ void certfp_free(ModData *m); -char *certfp_serialize(ModData *m); -void certfp_unserialize(char *str, ModData *m); +const char *certfp_serialize(ModData *m); +void certfp_unserialize(const char *str, ModData *m); int certfp_handshake(Client *client); int certfp_connect(Client *client); int certfp_whois(Client *client, Client *target); @@ -121,7 +121,7 @@ int certfp_connect(Client *client) { if (IsSecure(client)) { - char *fp = moddata_client_get(client, "certfp"); + const char *fp = moddata_client_get(client, "certfp"); if (fp && !iConf.no_connect_tls_info) sendnotice(client, "*** Your TLS certificate fingerprint is %s", fp); @@ -132,7 +132,7 @@ int certfp_connect(Client *client) int certfp_whois(Client *client, Client *target) { - char *fp = moddata_client_get(target, "certfp"); + const char *fp = moddata_client_get(target, "certfp"); if (fp) sendnumeric(client, RPL_WHOISCERTFP, target->name, fp); @@ -144,14 +144,14 @@ void certfp_free(ModData *m) safe_free(m->str); } -char *certfp_serialize(ModData *m) +const char *certfp_serialize(ModData *m) { if (!m->str) return NULL; return m->str; } -void certfp_unserialize(char *str, ModData *m) +void certfp_unserialize(const char *str, ModData *m) { safe_strdup(m->str, str); } diff --git a/src/modules/chanmodes/delayjoin.c b/src/modules/chanmodes/delayjoin.c index bdea14835..b9909474c 100644 --- a/src/modules/chanmodes/delayjoin.c +++ b/src/modules/chanmodes/delayjoin.c @@ -32,8 +32,8 @@ int delayjoin_is_ok(Client *client, Channel *channel, char mode, const char *par int moded_chanmode(Client *client, Channel *channel, MessageTag *mtags, const char *modebuf, const char *parabuf, time_t sendts, int samode); int moded_prechanmsg(Client *client, Channel *channel, MessageTag *mtags, const char *text, SendType sendtype); -char *moded_serialize(ModData *m); -void moded_unserialize(char *str, ModData *m); +const char *moded_serialize(ModData *m); +void moded_unserialize(const char *str, ModData *m); MOD_INIT() { @@ -395,12 +395,12 @@ int moded_prechanmsg(Client *client, Channel *channel, MessageTag *mtags, const return 0; } -char *moded_serialize(ModData *m) +const char *moded_serialize(ModData *m) { return m->i ? "1" : "0"; } -void moded_unserialize(char *str, ModData *m) +void moded_unserialize(const char *str, ModData *m) { m->i = atoi(str); } diff --git a/src/modules/extbans/certfp.c b/src/modules/extbans/certfp.c index 4f6c458d3..8d9a61bfa 100644 --- a/src/modules/extbans/certfp.c +++ b/src/modules/extbans/certfp.c @@ -113,9 +113,7 @@ const char *extban_certfp_conv_param(BanContext *b, Extban *extban) int extban_certfp_is_banned(BanContext *b) { - char *fp; - - fp = moddata_client_get(b->client, "certfp"); + const char *fp = moddata_client_get(b->client, "certfp"); if (!fp) return 0; /* not using TLS */ diff --git a/src/modules/geoip_base.c b/src/modules/geoip_base.c index 099d8ab7f..c54bfb07a 100644 --- a/src/modules/geoip_base.c +++ b/src/modules/geoip_base.c @@ -23,8 +23,8 @@ struct geoip_base_config_s { /* Forward declarations */ void geoip_base_free(ModData *m); -char *geoip_base_serialize(ModData *m); -void geoip_base_unserialize(char *str, ModData *m); +const char *geoip_base_serialize(ModData *m); +void geoip_base_unserialize(const char *str, ModData *m); int geoip_base_handshake(Client *client); int geoip_base_whois(Client *client, Client *target); int geoip_connect_extinfo(Client *client, NameValuePrioList **list); @@ -178,7 +178,7 @@ void geoip_base_free(ModData *m) } } -char *geoip_base_serialize(ModData *m) +const char *geoip_base_serialize(ModData *m) { static char buf[512]; GeoIPResult *geo; @@ -194,7 +194,7 @@ char *geoip_base_serialize(ModData *m) return buf; } -void geoip_base_unserialize(char *str, ModData *m) +void geoip_base_unserialize(const char *str, ModData *m) { char buf[512], *p=NULL, *varname, *value; char *country_name = NULL; diff --git a/src/modules/history_backend_mem.c b/src/modules/history_backend_mem.c index 21bc262b7..d443a18f1 100644 --- a/src/modules/history_backend_mem.c +++ b/src/modules/history_backend_mem.c @@ -404,7 +404,7 @@ int hbm_rehash_complete(void) return 0; } -char *history_storage_capability_parameter(Client *client) +const char *history_storage_capability_parameter(Client *client) { static char buf[128]; diff --git a/src/modules/link-security.c b/src/modules/link-security.c index e350e8240..76e8bed11 100644 --- a/src/modules/link-security.c +++ b/src/modules/link-security.c @@ -33,10 +33,10 @@ ModuleHeader MOD_HEADER }; /* Forward declarations */ -char *link_security_md_serialize(ModData *m); -void link_security_md_unserialize(char *str, ModData *m); +const char *link_security_md_serialize(ModData *m); +void link_security_md_unserialize(const char *str, ModData *m); EVENT(checklinksec); -char *link_security_capability_parameter(Client *client); +const char *link_security_capability_parameter(Client *client); CMD_FUNC(cmd_linksecurity); /* Global variables */ @@ -98,7 +98,7 @@ MOD_UNLOAD() */ #define LNKSECMAGIC 100 -char *link_security_md_serialize(ModData *m) +const char *link_security_md_serialize(ModData *m) { static char buf[32]; if (m->i == 0) @@ -107,7 +107,7 @@ char *link_security_md_serialize(ModData *m) return buf; } -void link_security_md_unserialize(char *str, ModData *m) +void link_security_md_unserialize(const char *str, ModData *m) { m->i = atoi(str) + LNKSECMAGIC; } @@ -178,7 +178,6 @@ EVENT(checklinksec) int last_local_link_security = local_link_security; int last_global_link_security = global_link_security; Client *client; - char *s; int v; int warning_sent = 0; @@ -194,7 +193,7 @@ EVENT(checklinksec) global_link_security = 2; list_for_each_entry(client, &global_server_list, client_node) { - s = moddata_client_get(client, "link-security"); + const char *s = moddata_client_get(client, "link-security"); if (s) { v = atoi(s); @@ -237,7 +236,7 @@ EVENT(checklinksec) } } -char *link_security_capability_parameter(Client *client) +const char *link_security_capability_parameter(Client *client) { return valtostr(effective_link_security); } @@ -246,8 +245,6 @@ char *link_security_capability_parameter(Client *client) CMD_FUNC(cmd_linksecurity) { Client *acptr; - char *s; - int v; if (!IsOper(client)) { @@ -260,15 +257,11 @@ CMD_FUNC(cmd_linksecurity) sendtxtnumeric(client, "= By server ="); list_for_each_entry(acptr, &global_server_list, client_node) { - v = -1; - s = moddata_client_get(acptr, "link-security"); + const char *s = moddata_client_get(acptr, "link-security"); if (s) - { - v = atoi(s); - sendtxtnumeric(client, "%s: level %d", acptr->name, v); - } else { + sendtxtnumeric(client, "%s: level %d", acptr->name, atoi(s)); + else sendtxtnumeric(client, "%s: level UNKNOWN", acptr->name); - } } sendtxtnumeric(client, "-"); diff --git a/src/modules/md.c b/src/modules/md.c index 894992703..f3a2a08de 100644 --- a/src/modules/md.c +++ b/src/modules/md.c @@ -23,11 +23,11 @@ void _broadcast_md_channel(ModDataInfo *mdi, Channel *channel, ModData *md); void _broadcast_md_member(ModDataInfo *mdi, Channel *channel, Member *m, ModData *md); void _broadcast_md_membership(ModDataInfo *mdi, Client *client, Membership *m, ModData *md); void _broadcast_md_globalvar(ModDataInfo *mdi, ModData *md); -void _broadcast_md_client_cmd(Client *except, Client *sender, Client *client, char *varname, char *value); -void _broadcast_md_channel_cmd(Client *except, Client *sender, Channel *channel, char *varname, char *value); -void _broadcast_md_member_cmd(Client *except, Client *sender, Channel *channel, Client *client, char *varname, char *value); -void _broadcast_md_membership_cmd(Client *except, Client *sender, Client *client, Channel *channel, char *varname, char *value); -void _broadcast_md_globalvar_cmd(Client *except, Client *sender, char *varname, char *value); +void _broadcast_md_client_cmd(Client *except, Client *sender, Client *client, const char *varname, const char *value); +void _broadcast_md_channel_cmd(Client *except, Client *sender, Channel *channel, const char *varname, const char *value); +void _broadcast_md_member_cmd(Client *except, Client *sender, Channel *channel, Client *client, const char *varname, const char *value); +void _broadcast_md_membership_cmd(Client *except, Client *sender, Client *client, Channel *channel, const char *varname, const char *value); +void _broadcast_md_globalvar_cmd(Client *except, Client *sender, const char *varname, const char *value); void _moddata_add_s2s_mtags(Client *client, MessageTag **mtags); void _moddata_extract_s2s_mtags(Client *client, MessageTag *mtags); void _send_moddata_client(Client *srv, Client *client); @@ -265,7 +265,7 @@ CMD_FUNC(cmd_md) } } -void _broadcast_md_client_cmd(Client *except, Client *sender, Client *client, char *varname, char *value) +void _broadcast_md_client_cmd(Client *except, Client *sender, Client *client, const char *varname, const char *value) { if (value) { @@ -279,7 +279,7 @@ void _broadcast_md_client_cmd(Client *except, Client *sender, Client *client, ch } } -void _broadcast_md_channel_cmd(Client *except, Client *sender, Channel *channel, char *varname, char *value) +void _broadcast_md_channel_cmd(Client *except, Client *sender, Channel *channel, const char *varname, const char *value) { if (value) sendto_server(except, 0, 0, NULL, ":%s MD %s %s %s :%s", @@ -289,7 +289,7 @@ void _broadcast_md_channel_cmd(Client *except, Client *sender, Channel *channel, sender->id, "channel", channel->name, varname); } -void _broadcast_md_member_cmd(Client *except, Client *sender, Channel *channel, Client *client, char *varname, char *value) +void _broadcast_md_member_cmd(Client *except, Client *sender, Channel *channel, Client *client, const char *varname, const char *value) { if (value) { @@ -303,7 +303,7 @@ void _broadcast_md_member_cmd(Client *except, Client *sender, Channel *channel, } } -void _broadcast_md_membership_cmd(Client *except, Client *sender, Client *client, Channel *channel, char *varname, char *value) +void _broadcast_md_membership_cmd(Client *except, Client *sender, Client *client, Channel *channel, const char *varname, const char *value) { if (value) { @@ -317,7 +317,7 @@ void _broadcast_md_membership_cmd(Client *except, Client *sender, Client *client } } -void _broadcast_md_globalvar_cmd(Client *except, Client *sender, char *varname, char *value) +void _broadcast_md_globalvar_cmd(Client *except, Client *sender, const char *varname, const char *value) { if (value) { @@ -339,35 +339,35 @@ void _broadcast_md_globalvar_cmd(Client *except, Client *sender, char *varname, void _broadcast_md_client(ModDataInfo *mdi, Client *client, ModData *md) { - char *value = md ? mdi->serialize(md) : NULL; + const char *value = md ? mdi->serialize(md) : NULL; broadcast_md_client_cmd(NULL, &me, client, mdi->name, value); } void _broadcast_md_channel(ModDataInfo *mdi, Channel *channel, ModData *md) { - char *value = md ? mdi->serialize(md) : NULL; + const char *value = md ? mdi->serialize(md) : NULL; broadcast_md_channel_cmd(NULL, &me, channel, mdi->name, value); } void _broadcast_md_member(ModDataInfo *mdi, Channel *channel, Member *m, ModData *md) { - char *value = md ? mdi->serialize(md) : NULL; + const char *value = md ? mdi->serialize(md) : NULL; broadcast_md_member_cmd(NULL, &me, channel, m->client, mdi->name, value); } void _broadcast_md_membership(ModDataInfo *mdi, Client *client, Membership *m, ModData *md) { - char *value = md ? mdi->serialize(md) : NULL; + const char *value = md ? mdi->serialize(md) : NULL; broadcast_md_membership_cmd(NULL, &me, client, m->channel, mdi->name, value); } void _broadcast_md_globalvar(ModDataInfo *mdi, ModData *md) { - char *value = md ? mdi->serialize(md) : NULL; + const char *value = md ? mdi->serialize(md) : NULL; broadcast_md_globalvar_cmd(NULL, &me, mdi->name, value); } @@ -381,7 +381,7 @@ void _send_moddata_client(Client *srv, Client *client) { if ((mdi->type == MODDATATYPE_CLIENT) && mdi->sync && mdi->serialize) { - char *value = mdi->serialize(&moddata_client(client, mdi)); + const char *value = mdi->serialize(&moddata_client(client, mdi)); if (value) sendto_one(srv, NULL, ":%s MD %s %s %s :%s", me.id, "client", client->id, mdi->name, value); @@ -402,7 +402,7 @@ void _moddata_add_s2s_mtags(Client *client, MessageTag **mtags_list) if ((mdi->type == MODDATATYPE_CLIENT) && (mdi->sync == MODDATA_SYNC_EARLY) && mdi->serialize) { MessageTag *m; - char *value = mdi->serialize(&moddata_client(client, mdi)); + const char *value = mdi->serialize(&moddata_client(client, mdi)); if (!value) continue; snprintf(name, sizeof(name), "s2s-md/%s", mdi->name); @@ -454,7 +454,7 @@ void _send_moddata_channel(Client *srv, Channel *channel) { if ((mdi->type == MODDATATYPE_CHANNEL) && mdi->sync && mdi->serialize) { - char *value = mdi->serialize(&moddata_channel(channel, mdi)); + const char *value = mdi->serialize(&moddata_channel(channel, mdi)); if (value) sendto_one(srv, NULL, ":%s MD %s %s %s :%s", me.id, "channel", channel->name, mdi->name, value); @@ -481,7 +481,7 @@ void _send_moddata_members(Client *srv) { if ((mdi->type == MODDATATYPE_MEMBER) && mdi->sync && mdi->serialize) { - char *value = mdi->serialize(&moddata_member(m, mdi)); + const char *value = mdi->serialize(&moddata_member(m, mdi)); if (value) sendto_one(srv, NULL, ":%s MD %s %s:%s %s :%s", me.id, "member", channel->name, client->id, mdi->name, value); @@ -505,7 +505,7 @@ void _send_moddata_members(Client *srv) { if ((mdi->type == MODDATATYPE_MEMBERSHIP) && mdi->sync && mdi->serialize) { - char *value = mdi->serialize(&moddata_membership(m, mdi)); + const char *value = mdi->serialize(&moddata_membership(m, mdi)); if (value) sendto_one(srv, NULL, ":%s MD %s %s:%s %s :%s", me.id, "membership", client->id, m->channel->name, mdi->name, value); diff --git a/src/modules/metadata.c b/src/modules/metadata.c index eb6c4aa61..1d7501bce 100644 --- a/src/modules/metadata.c +++ b/src/modules/metadata.c @@ -117,7 +117,7 @@ CMD_FUNC(cmd_metadata); CMD_FUNC(cmd_metadata_remote); CMD_FUNC(cmd_metadata_local); EVENT(metadata_queue_evt); -char *metadata_cap_param(Client *client); +const char *metadata_cap_param(Client *client); char *metadata_isupport_param(void); int metadata_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs); int metadata_configposttest(int *errs); @@ -396,7 +396,7 @@ MOD_UNLOAD() { return MOD_SUCCESS; } -char *metadata_cap_param(Client *client) +const char *metadata_cap_param(Client *client) { static char buf[20]; ircsnprintf(buf, sizeof(buf), "maxsub=%d", metadata_settings.max_subscriptions); diff --git a/src/modules/plaintext-policy.c b/src/modules/plaintext-policy.c index 9eca72b4c..d5159d682 100644 --- a/src/modules/plaintext-policy.c +++ b/src/modules/plaintext-policy.c @@ -52,7 +52,7 @@ MOD_UNLOAD() return MOD_SUCCESS; } -char *plaintext_policy_capability_parameter(Client *client) +const char *plaintext_policy_capability_parameter(Client *client) { static char buf[128]; diff --git a/src/modules/reputation.c b/src/modules/reputation.c index 767afef63..eba35eab7 100644 --- a/src/modules/reputation.c +++ b/src/modules/reputation.c @@ -132,8 +132,8 @@ ModDataInfo *reputation_md; /* Module Data structure which we acquire */ /* Forward declarations */ void reputation_md_free(ModData *m); -char *reputation_md_serialize(ModData *m); -void reputation_md_unserialize(char *str, ModData *m); +const char *reputation_md_serialize(ModData *m); +void reputation_md_unserialize(const char *str, ModData *m); void reputation_config_setdefaults(struct cfgstruct *cfg); void reputation_free_config(struct cfgstruct *cfg); CMD_FUNC(reputation_cmd); @@ -1329,7 +1329,7 @@ void reputation_md_free(ModData *m) m->l = 0; } -char *reputation_md_serialize(ModData *m) +const char *reputation_md_serialize(ModData *m) { static char buf[32]; if (m->i == 0) @@ -1338,7 +1338,7 @@ char *reputation_md_serialize(ModData *m) return buf; } -void reputation_md_unserialize(char *str, ModData *m) +void reputation_md_unserialize(const char *str, ModData *m) { m->i = atoi(str); } diff --git a/src/modules/sasl.c b/src/modules/sasl.c index 19b3501dc..5d7146f4a 100644 --- a/src/modules/sasl.c +++ b/src/modules/sasl.c @@ -33,9 +33,9 @@ ModuleHeader MOD_HEADER /* Forward declarations */ void saslmechlist_free(ModData *m); -char *saslmechlist_serialize(ModData *m); -void saslmechlist_unserialize(char *str, ModData *m); -char *sasl_capability_parameter(Client *client); +const char *saslmechlist_serialize(ModData *m); +void saslmechlist_unserialize(const char *str, ModData *m); +const char *sasl_capability_parameter(Client *client); int sasl_server_synced(Client *client); int sasl_account_login(Client *client, MessageTag *mtags); EVENT(sasl_timeout); @@ -233,7 +233,7 @@ CMD_FUNC(cmd_authenticate) if (agent_p == NULL) { char *addr = BadPtr(client->ip) ? "0" : client->ip; - char *certfp = moddata_client_get(client, "certfp"); + const char *certfp = moddata_client_get(client, "certfp"); sendto_server(NULL, 0, 0, NULL, ":%s SASL %s %s H %s %s", me.name, SASL_SERVER, client->id, addr, addr); @@ -416,19 +416,19 @@ void saslmechlist_free(ModData *m) safe_free(m->str); } -char *saslmechlist_serialize(ModData *m) +const char *saslmechlist_serialize(ModData *m) { if (!m->str) return NULL; return m->str; } -void saslmechlist_unserialize(char *str, ModData *m) +void saslmechlist_unserialize(const char *str, ModData *m) { safe_strdup(m->str, str); } -char *sasl_capability_parameter(Client *client) +const char *sasl_capability_parameter(Client *client) { Client *server; diff --git a/src/modules/server.c b/src/modules/server.c index f220f561f..5c2524bb9 100644 --- a/src/modules/server.c +++ b/src/modules/server.c @@ -1492,8 +1492,8 @@ int server_sync(Client *client, ConfigItem_link *aconf, int incoming) void tls_link_notification_verify(Client *client, ConfigItem_link *aconf) { - char *spki_fp; - char *tls_fp; + const char *spki_fp; + const char *tls_fp; char *errstr = NULL; int verify_ok; diff --git a/src/modules/sts.c b/src/modules/sts.c index bc014ced6..35a8c78a2 100644 --- a/src/modules/sts.c +++ b/src/modules/sts.c @@ -78,7 +78,7 @@ int sts_capability_visible(Client *client) return 0; } -char *sts_capability_parameter(Client *client) +const char *sts_capability_parameter(Client *client) { TLSOptions *ssl; static char buf[256]; diff --git a/src/modules/tkl.c b/src/modules/tkl.c index 14d5353a8..69a9af6a2 100644 --- a/src/modules/tkl.c +++ b/src/modules/tkl.c @@ -4434,7 +4434,7 @@ void ban_target_to_tkl_layer(BanTarget ban_target, BanAction action, Client *cli } else if (ban_target == BAN_TARGET_CERTFP) { - char *fp = moddata_client_get(client, "certfp"); + const char *fp = moddata_client_get(client, "certfp"); if (fp) { /* Place a ban on ~S:sha256sumofclientcertificate */ diff --git a/src/modules/tls_cipher.c b/src/modules/tls_cipher.c index 6e024b3e8..a7e84be0d 100644 --- a/src/modules/tls_cipher.c +++ b/src/modules/tls_cipher.c @@ -17,8 +17,8 @@ ModuleHeader MOD_HEADER /* Forward declarations */ void tls_cipher_free(ModData *m); -char *tls_cipher_serialize(ModData *m); -void tls_cipher_unserialize(char *str, ModData *m); +const char *tls_cipher_serialize(ModData *m); +void tls_cipher_unserialize(const char *str, ModData *m); int tls_cipher_handshake(Client *client); int tls_cipher_connect(Client *client); int tls_cipher_whois(Client *client, Client *target); @@ -63,7 +63,7 @@ int tls_cipher_handshake(Client *client) { if (client->local->ssl) { - char *cipher = tls_get_cipher(client); + const char *cipher = tls_get_cipher(client); if (!cipher) return 0; @@ -78,14 +78,14 @@ void tls_cipher_free(ModData *m) safe_free(m->str); } -char *tls_cipher_serialize(ModData *m) +const char *tls_cipher_serialize(ModData *m) { if (!m->str) return NULL; return m->str; } -void tls_cipher_unserialize(char *str, ModData *m) +void tls_cipher_unserialize(const char *str, ModData *m) { safe_strdup(m->str, str); } diff --git a/src/modules/webirc.c b/src/modules/webirc.c index 404ea4e3b..7c79b6381 100644 --- a/src/modules/webirc.c +++ b/src/modules/webirc.c @@ -54,8 +54,8 @@ int webirc_config_test(ConfigFile *, ConfigEntry *, int, int *); int webirc_config_run(ConfigFile *, ConfigEntry *, int); void webirc_free_conf(void); void delete_webircblock(ConfigItem_webirc *e); -char *webirc_md_serialize(ModData *m); -void webirc_md_unserialize(char *str, ModData *m); +const char *webirc_md_serialize(ModData *m); +void webirc_md_unserialize(const char *str, ModData *m); void webirc_md_free(ModData *md); int webirc_secure_connect(Client *client); @@ -281,7 +281,7 @@ int webirc_config_run(ConfigFile *cf, ConfigEntry *ce, int type) return 0; } -char *webirc_md_serialize(ModData *m) +const char *webirc_md_serialize(ModData *m) { static char buf[32]; if (m->i == 0) @@ -290,7 +290,7 @@ char *webirc_md_serialize(ModData *m) return buf; } -void webirc_md_unserialize(char *str, ModData *m) +void webirc_md_unserialize(const char *str, ModData *m) { m->i = atoi(str); } diff --git a/src/modules/whox.c b/src/modules/whox.c index d8bfd6300..41c9f443f 100644 --- a/src/modules/whox.c +++ b/src/modules/whox.c @@ -81,8 +81,8 @@ static void do_who(Client *client, Client *acptr, Channel *channel, struct who_f static void do_who_on_channel(Client *client, Channel *channel, int member, int operspy, struct who_format *fmt); static int convert_classical_who_request(Client *client, int *parc, char *parv[], char **orig_mask, struct who_format *fmt); -char *whox_md_serialize(ModData *m); -void whox_md_unserialize(char *str, ModData *m); +const char *whox_md_serialize(ModData *m); +void whox_md_unserialize(const char *str, ModData *m); void whox_md_free(ModData *md); static void append_format(char *buf, size_t bufsize, size_t *pos, const char *fmt, ...) __attribute__((format(printf,4,5))); @@ -127,7 +127,7 @@ MOD_UNLOAD() } /** whox module data operations: serialize (rare) */ -char *whox_md_serialize(ModData *m) +const char *whox_md_serialize(ModData *m) { static char buf[32]; if (m->i == 0) @@ -137,7 +137,7 @@ char *whox_md_serialize(ModData *m) } /** whox module data operations: unserialize (rare) */ -void whox_md_unserialize(char *str, ModData *m) +void whox_md_unserialize(const char *str, ModData *m) { m->i = atoi(str); } diff --git a/src/send.c b/src/send.c index 3ea07cece..bc3b503ae 100644 --- a/src/send.c +++ b/src/send.c @@ -925,7 +925,7 @@ void send_cap_notify(int add, char *token) { if (add) { - char *args = NULL; + const char *args = NULL; if (clicap) { if (clicap->visible && !clicap->visible(client)) diff --git a/src/tls.c b/src/tls.c index d3846279b..ce6632bea 100644 --- a/src/tls.c +++ b/src/tls.c @@ -605,10 +605,10 @@ void SSL_set_nonblocking(SSL *s) } /** Get TLS ciphersuite */ -char *tls_get_cipher(Client *client) +const char *tls_get_cipher(Client *client) { static char buf[256]; - char *cached; + const char *cached; cached = moddata_client_get(client, "tls_cipher"); if (cached) diff --git a/src/user.c b/src/user.c index db0ee82be..4b5abe6ea 100644 --- a/src/user.c +++ b/src/user.c @@ -944,7 +944,8 @@ const char *get_security_groups(Client *client) const char *get_connect_extinfo(Client *client) { static char retbuf[512]; - char tmp[512], *s; + char tmp[512]; + const char *s; const char *secgroups; NameValuePrioList *list = NULL, *e;