diff --git a/include/client.h b/include/client.h index 8f370906..26809f3d 100644 --- a/include/client.h +++ b/include/client.h @@ -121,8 +121,8 @@ struct ZipStats struct MetadataEntry { - char key[NICKLEN+1]; - char value[TOPICLEN]; + char key[METADATAKEYLEN]; + char value[METADATAVALUELEN]; }; struct Client diff --git a/include/ircd_defs.h b/include/ircd_defs.h index 071c92f0..cb26b953 100644 --- a/include/ircd_defs.h +++ b/include/ircd_defs.h @@ -111,6 +111,13 @@ #define BANREASONLEN 390 /* kline/dline */ #define AWAYLEN TOPICLEN #define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */ +#define METADATAKEYLEN 31 +/* :012345678901234567890123456789012345678901234567890123456789123 792 * 012345678901234567890123456789 012345678901234567890123456789 : + * takes at most 137 bytes + * :123456789 ENCAP * PRESENCE 012345678901234567890123456789 : + * takes at most 63 bytes + * */ +#define METADATAVALUELEN 300 /* 23+1 for \0 */ #define KEYLEN 24 diff --git a/src/client.c b/src/client.c index 32f950a2..a395ec81 100644 --- a/src/client.c +++ b/src/client.c @@ -1753,15 +1753,15 @@ set_metadata(struct Client *client_p, const char *key, const char *value) if (md == NULL) { md = rb_bh_alloc(metadata_heap); - rb_strlcpy(md->key, key, NICKLEN); + rb_strlcpy(md->key, key, sizeof md->key); irc_dictionary_add(client_p->user->metadata, md->key, md); } else if (!strcmp(md->key, key) && !strcmp(md->value, value)) return; else - rb_strlcpy(md->key, key, NICKLEN); + rb_strlcpy(md->key, key, sizeof md->key); - rb_strlcpy(md->value, value, TOPICLEN); + rb_strlcpy(md->value, value, sizeof md->value); } sendto_common_channels_local_with_capability(client_p, CLICAP_PRESENCE, form_str(RPL_METADATACHG), me.name, client_p->name, key, value);