aboutsummaryrefslogtreecommitdiffstats
path: root/ircd/msgbuf.c
Commit message (Expand)AuthorAgeFilesLines
* Separate client vs server caps•••Instead of overloading the same field in a LocalUser, have separate fields for client caps vs server caps. While only one of these will ever be nonzero, it reduces error by making it explicit which set of caps is being checked. IsCapable and friends have been split as well, to IsClientCapable and IsServerCapable. Finally, both fields have been updated to uint64_t (server caps were approaching the current limit) and all APIs that reference caps updated to uint64_t as well (no more signed/unsigned mismatches). Gravatar Ryan Schmidt2026-03-171-6/+6
* Revert "msgbuf: duplicate the string during partial parse and constify line" ...•••This reverts commit 5b253939da8f6b0a44ce6787ed12e26450ac6a63 to fix a memory leak: ``` ==825564== 818 bytes in 4 blocks are definitely lost in loss record 616 of 648 ==825564== at 0x4844818: malloc (vg_replace_malloc.c:446) ==825564== by 0x49CD7A9: strdup (strdup.c:42) ==825564== by 0x4888A2E: msgbuf_partial_parse (msgbuf.c:143) ==825564== by 0x489DA84: build_msgbuf (send.c:276) ==825564== by 0x489DA84: sendto_one_numeric (send.c:431) ==825564== by 0x48A3CD7: show_isupport (supported.c:181) ==825564== by 0x489A9F2: user_welcome (s_user.c:1433) ==825564== by 0x489B114: register_local_user (s_user.c:718) ==825564== by 0x488FC08: handle_command (parse.c:310) ==825564== by 0x488FC08: parse (parse.c:224) ==825564== by 0x488EEF8: parse_client_queued.part.0 (packet.c:67) ==825564== by 0x488F084: parse_client_queued (packet.c:49) ==825564== by 0x488F084: read_packet (packet.c:306) ==825564== by 0x4B3C47B: rb_select_epoll (epoll.c:199) ==825564== by 0x4B3716F: rb_select (commio.c:2038) ==825564== [...] ==825564== ==825564== 3,012 bytes in 15 blocks are definitely lost in loss record 627 of 648 ==825564== at 0x4844818: malloc (vg_replace_malloc.c:446) ==825564== by 0x49CD7A9: strdup (strdup.c:42) ==825564== by 0x4888A2E: msgbuf_partial_parse (msgbuf.c:143) ==825564== by 0x489D3CE: build_msgbuf (send.c:276) ==825564== by 0x489D3CE: sendto_realops_snomask (send.c:1431) ==825564== by 0x4887C0D: load_a_module (modules.c:712) ==825564== by 0x488801D: load_core_modules (modules.c:257) ==825564== by 0x488124A: solanum_main (ircd.c:664) ==825564== by 0x494DCA7: (below main) (libc_start_call_main.h:58) ```Gravatar Val Lorentz2025-10-111-2/+2
* Fix typing module decl and send 417 in more cases•••The typing module declaration had a copy/paste error that has now been corrected, and we now send 417 ERR_INPUTTOOLONG in cases where parsing the line into a MsgBuf fails because it overflowed the 8191+512 byte buffer while processing tags or the message origin. Gravatar Ryan Schmidt2025-10-101-5/+5
* Address review comments•••Correctly sent ERR_INPUTTOOLONG if the incoming tags portion from a client is too long. The previous calculation did not take into account the fact we added null terminators after every tag key and value. Since msgbuf_parse is used for both server and client input, we expose the length of the original tags portion of the buffer in the MsgBuf struct rather than abort msgbuf_parse if it is too long, since the only time truncation is explicitly not allowed is for incoming tags from client messages. Additionally, make join_sep functional in format_client_tags(). Gravatar Ryan Schmidt2025-10-101-25/+25
* Update MsgBuf for better tags support•••Note: Future commits within this PR update call sites to leverage these changes. I opted to keep each individual commit smaller to make them easier to review in series. When parsing a line into a MsgBuf, we now keep track of whether the final parameter had a leading colon or not, so that we can roundtrip unparse it with said colon even if the final parameter lacks a space or otherwise doesn't require the leading colon. solanum sends multiple such messages and clients may be coded to expect colons in various situations, so adding this roundtrip support maintains backwards compatibility for when all outbound messages get parsed into MsgBuf and then unparsed before being sent off. The MsgBuf cache now keeps track of two messages: one with a "local" source and one with a "remote" source. Many send functions, e.g. the sendto_channel family, use ids for the sender when sending remotely but use the hostmask or server name for local sends. When forcing outbound messages into a parse/unparse loop we can no longer just ad-hoc assemble strings together like the current linebuf code does, so instead we cache both variants to avoid needless string formatting operations in tight send loops. Unparsing tags from a MsgBuf now enforces that the server tags and client tags portions do not exceed 4094 bytes each, and that server tags always come before client tags. Excess data is truncated. Gravatar Ryan Schmidt2025-10-101-88/+144
* fix: remove cruft and fix msgbuf_parseGravatar Raito Bezarius2025-10-101-1/+1
* msgbuf: duplicate the string during partial parse and constify lineGravatar Raito Bezarius2025-10-101-2/+2
* message-tags: facility to manipulate client-tags•••It provides for hook facilities to client-only tags: - messages can be dropped silently ; - messages can be edited ; - messages can be stripped from a client-only tag Gravatar Raito Bezarius2025-10-101-0/+8
* msgbuf: Add msgbuf_get_tagGravatar Ed Kellett2025-10-101-0/+13
* msgbuf: use only relevant caps for the cache keyGravatar Ed Kellett2021-06-131-0/+2
* msgbuf_cache_get: Don't create cycle when evictingGravatar Ed Kellett2021-06-081-0/+4
* Mailmap and copyright update for AriadneGravatar Ariadne Conill2021-06-011-1/+1
* Innovation by sedGravatar Ed Kellett2020-10-151-1/+1
* m_alias: Preserve protocol framing charactersGravatar Ed Kellett2020-07-051-0/+35
* ircd: send tags on every message•••Simplify linebuf by introducing fsnprint to manage a list of printfs. Add a msgbuf unparse cache for send functions that loop. Gravatar Simon Arlott2017-08-061-9/+131
* tests: add msgbuf_parse testsGravatar Simon Arlott2017-07-291-1/+1
* msgbuf: correctly split buffers into IRCv3 tags and RFC1459 message dataGravatar Simon Arlott2017-07-291-71/+192
* librb: remove unnecessary NULL from the end of rb_string_to_array outputGravatar Simon Arlott2017-07-291-8/+4
* msgbuf: don't append a ';' unless there are existing tags•••When both account-tag and server-time are present but the client doesn't have the first (i == 0) of these enabled. They will get an erroneous ';' after the '@'. Track whether or not there are tags present, and use this to determine whether to add the ';' or not. Also remove the extra function that loops over all of the tags by using this flag to handle the case where there are no tags being written. Gravatar Simon Arlott2016-12-041-18/+8
* msgbuf_parse: rb_string_to_array outputs to a MAXPARA+1 size arrayGravatar Simon Arlott2016-10-221-1/+1
* msgbuf: Fix remote crash vulnerability due to malformed message tag.•••Fixes #218 Reported-by: ManiacTwister <github@s7t.de> Gravatar Aaron Jones2016-09-111-0/+2
* More cleanupGravatar Matt Ullman2016-03-231-11/+4
* Cleanup warningsGravatar Matt Ullman2016-03-211-2/+0
* msgbuf: msgbuf_unparse_tags(): don't send a tags sigil unless tags will actua...Gravatar William Pitcock2016-02-201-0/+17
* msgbuf: allow for an explicit target to be definedGravatar William Pitcock2016-02-201-0/+3
* send: implement partial support for outbound tags (enough for account-tag as ...Gravatar William Pitcock2016-02-201-1/+4
* msgbuf: make msgbuf_unparse_prefix() publicGravatar William Pitcock2016-02-201-1/+1
* msgbuf: implement msgbuf_vunparse_fmt() and friendsGravatar William Pitcock2016-02-201-0/+40
* msgbuf: handle me.name properlyGravatar William Pitcock2016-02-201-2/+3
* msgbuf: add some message building codeGravatar William Pitcock2016-02-201-0/+71
* msgbuf: msgbuf_append_tag(): add support for attaching a specific capability bitGravatar William Pitcock2016-02-131-1/+1
* msgbuf: do a better job of handling gotchas with parsing tagsGravatar William Pitcock2016-02-101-5/+12
* msgbuf: improve parse logicGravatar William Pitcock2016-02-101-5/+7
* msgbuf: implement msgbuf_parse()Gravatar William Pitcock2016-02-101-0/+104