1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 13:13:13 +02:00

Update cmode.free_param definition to fix memleak due to yesterdays commit.

And update release notes technical note so it actually refers to the
correct channel mode function :D
This commit is contained in:
Bram Matthys
2023-04-02 08:24:00 +02:00
parent 8ea50d38a3
commit b914997a1c
8 changed files with 23 additions and 20 deletions
+4 -3
View File
@@ -74,9 +74,10 @@ in progress and not a stable version.
directive now accepts wildcards, eg `blacklist-module rpc/*;`
### Developers and protocol:
* The `cmode.put_param` is now `int` instead of `void`. You normally
`return 0` here. You can `return 1` if you resist freeing, which is
rare and only used by `+F` with set::anti-flood::channel::default-profile.
* The `cmode.free_param` definition changed. It now has an extra argument
`int soft` and for return value you will normally `return 0` here.
You can `return 1` if you resist freeing, which is rare and only used by
`+F` with set::anti-flood::channel::default-profile.
* JSON-RPC supports
[UNIX domain sockets](https://www.unrealircd.org/docs/JSON-RPC:Technical_documentation#UNIX_domain_socket)
for making RPC calls. If those are used, we now split on `\n` (newline)
+5 -3
View File
@@ -285,11 +285,13 @@ struct Cmode {
/** Free and remove parameter from list.
* This function pointer is NULL (unused) for modes without parameters.
* @param parastruct The parameter struct
* @param parastruct The parameter struct
* @param soft This is set to 1 if you may 'resist freeing'
* (used by floodprot module to have active F profile even if -F).
* @returns Normally return 0, must return 1 if it 'resisted' freeing.
* @note In most cases you will just call safe_free() on 'list'
*/
int (*free_param)(void *parastruct);
int (*free_param)(void *parastruct, int soft);
/** duplicate a struct and return a pointer to duplicate.
* This function pointer is NULL (unused) for modes without parameters.
@@ -348,7 +350,7 @@ typedef struct {
void * (*put_param)(void *, const char *);
const char * (*get_param)(void *);
const char * (*conv_param)(const char *, Client *, Channel *);
int (*free_param)(void *);
int (*free_param)(void *, int);
void * (*dup_struct)(void *);
int (*sjoin_check)(Channel *, void *, void *);
char local;
+3 -3
View File
@@ -534,7 +534,7 @@ static void unload_extcmode_commit(Cmode *cmode)
}
free_message_tags(mtags);
cmode->free_param(GETPARASTRUCT(channel, cmode->letter));
cmode->free_param(GETPARASTRUCT(channel, cmode->letter), 0);
channel->mode.mode &= ~cmode->mode;
}
}
@@ -627,7 +627,7 @@ void cm_putparameter(Channel *channel, char mode, const char *str)
*/
void cm_freeparameter(Channel *channel, char mode)
{
int n = GETPARAMHANDLERBYLETTER(mode)->free_param(GETPARASTRUCT(channel, mode));
int n = GETPARAMHANDLERBYLETTER(mode)->free_param(GETPARASTRUCT(channel, mode), 1);
if (n == 0)
GETPARASTRUCT(channel, mode) = NULL;
}
@@ -714,7 +714,7 @@ void extcmode_free_paramlist(void **ar)
handler = GETPARAMHANDLERBYSLOT(i);
if (!handler)
continue; /* nothing here... */
handler->free_param(ar[handler->param_slot]);
handler->free_param(ar[handler->param_slot], 0);
ar[handler->param_slot] = NULL;
}
}
+3 -3
View File
@@ -152,7 +152,7 @@ int cmodef_is_ok(Client *client, Channel *channel, char mode, const char *para,
void *cmodef_put_param(void *r_in, const char *param);
const char *cmodef_get_param(void *r_in);
const char *cmodef_conv_param(const char *param_in, Client *client, Channel *channel);
int cmodef_free_param(void *r);
int cmodef_free_param(void *r, int soft);
void *cmodef_dup_struct(void *r_in);
int cmodef_sjoin_check(Channel *channel, void *ourx, void *theirx);
int cmodef_profile_is_ok(Client *client, Channel *channel, char mode, const char *param, int type, int what);
@@ -879,14 +879,14 @@ const char *cmodef_conv_param(const char *param_in, Client *client, Channel *cha
return retbuf;
}
int cmodef_free_param(void *r)
int cmodef_free_param(void *r, int soft)
{
ChannelFloodProtection *fld = (ChannelFloodProtection *)r;
if (!fld)
return 0;
if (fld->profile && cfg.default_profile)
if (soft && fld->profile && cfg.default_profile)
{
/* Resist freeing */
if (strcmp(fld->profile, cfg.default_profile))
+2 -2
View File
@@ -50,7 +50,7 @@ int history_chanmode_is_ok(Client *client, Channel *channel, char mode, const ch
void *history_chanmode_put_param(void *r_in, const char *param);
const char *history_chanmode_get_param(void *r_in);
const char *history_chanmode_conv_param(const char *param, Client *client, Channel *channel);
int history_chanmode_free_param(void *r);
int history_chanmode_free_param(void *r, int soft);
void *history_chanmode_dup_struct(void *r_in);
int history_chanmode_sjoin_check(Channel *channel, void *ourx, void *theirx);
int history_channel_destroy(Channel *channel, int *should_destroy);
@@ -576,7 +576,7 @@ const char *history_chanmode_get_param(void *h_in)
}
/** Free channel mode */
int history_chanmode_free_param(void *r)
int history_chanmode_free_param(void *r, int soft)
{
safe_free(r);
return 0;
+2 -2
View File
@@ -45,7 +45,7 @@ int cmode_key_is_ok(Client *client, Channel *channel, char mode, const char *par
void *cmode_key_put_param(void *r_in, const char *param);
const char *cmode_key_get_param(void *r_in);
const char *cmode_key_conv_param(const char *param_in, Client *client, Channel *channel);
int cmode_key_free_param(void *r);
int cmode_key_free_param(void *r, int soft);
void *cmode_key_dup_struct(void *r_in);
int cmode_key_sjoin_check(Channel *channel, void *ourx, void *theirx);
int is_valid_key(const char *key);
@@ -162,7 +162,7 @@ const char *cmode_key_conv_param(const char *param, Client *client, Channel *cha
return retbuf;
}
int cmode_key_free_param(void *r)
int cmode_key_free_param(void *r, int soft)
{
safe_free(r);
return 0;
+2 -2
View File
@@ -48,7 +48,7 @@ int cmode_limit_is_ok(Client *client, Channel *channel, char mode, const char *p
void *cmode_limit_put_param(void *r_in, const char *param);
const char *cmode_limit_get_param(void *r_in);
const char *cmode_limit_conv_param(const char *param_in, Client *client, Channel *channel);
int cmode_limit_free_param(void *r);
int cmode_limit_free_param(void *r, int soft);
void *cmode_limit_dup_struct(void *r_in);
int cmode_limit_sjoin_check(Channel *channel, void *ourx, void *theirx);
int transform_channel_limit(const char *param);
@@ -159,7 +159,7 @@ const char *cmode_limit_conv_param(const char *param, Client *client, Channel *c
return retbuf;
}
int cmode_limit_free_param(void *r)
int cmode_limit_free_param(void *r, int soft)
{
safe_free(r);
return 0;
+2 -2
View File
@@ -49,7 +49,7 @@ int cmodeL_is_ok(Client *client, Channel *channel, char mode, const char *para,
void *cmodeL_put_param(void *r_in, const char *param);
const char *cmodeL_get_param(void *r_in);
const char *cmodeL_conv_param(const char *param_in, Client *client, Channel *channel);
int cmodeL_free_param(void *r);
int cmodeL_free_param(void *r, int soft);
void *cmodeL_dup_struct(void *r_in);
int cmodeL_sjoin_check(Channel *channel, void *ourx, void *theirx);
@@ -178,7 +178,7 @@ const char *cmodeL_conv_param(const char *param, Client *client, Channel *channe
return param;
}
int cmodeL_free_param(void *r)
int cmodeL_free_param(void *r, int soft)
{
safe_free(r);
return 0;