[ircd-ratbox] Trailing whitespace in MODE message after SJOIN

Will Storey will at summercat.com
Thu Sep 22 04:59:36 UTC 2016


Hi again,

Sorry to bother about this again. I noticed a couple more cases we can have
trailing spaces, so I updated my patch to account for them.

The first new case is the MODE command. You can see a single trailing space
when you remove a single mode without a parameter. It can happen with
several modes, as long as you don't have a parameter. Example: MODE #test
-t.

The second new case you can see when servers connect and the server removes
modes, such as if a client gained ops during a netsplit. It will only arise
in mode lines not hitting the max mode count.

I made similar changes to the first for these in the patch. I also looked
to see if I could find any more such cases (at least in messages sent to
clients), and have been unable to see any.

I've also realized that the IRC RFCs aren't widely followed, so changing
for them doesn't make a lot of sense. But since these trailing characters
are not needed, I figure there's no point sending them either way.

Thank you.

On Wed 2016-09-07 22:25:30 -0700, Will Storey wrote:
> Hi,
> 
> I noticed that there are trailing spaces in some cases in the MODE messages
> sent by servers when processing an SJOIN message. I saw this happen when
> servers join and modes got bursted over.
> 
> Here is an example of what I mean (message wrapped in [] to show spaces):
> 
> [:test.summercat.com MODE #test +o will   ]
> 
> I traced this to ms_sjoin() where there is this format string:
> 
> ":%s MODE %s %s %s %s %s %s"
> 
> The last 3 %s arguments may be blank which leads to these trailing spaces.
> 
> It is not exactly a huge problem I know. I only ran into it as I was basing
> some parsing code off RFC 2812's grammar. In RFC 1459 this appears possibly
> valid, but not in RFC 2812. Perhaps it is still worth making a small update
> for though.
> 
> I have attached a diff with a possible solution.
> 
> Thank you for your time.

> --- modules/core/m_join.c	(revision 29442)
> +++ modules/core/m_join.c	(working copy)
> @@ -812,10 +812,12 @@
>  	if(pargs)
>  	{
>  		sendto_channel_local(ALL_MEMBERS, chptr,
> -				     ":%s MODE %s %s %s %s %s %s",
> +				     ":%s MODE %s %s %s%s%s%s%s%s%s",
>  				     source_p->name, chptr->chname, modebuf,
> -				     para[0], CheckEmpty(para[1]), CheckEmpty(para[2]),
> -				     CheckEmpty(para[3]));
> +				     para[0],
> +				     EmptyString(para[1]) ? "" : " ", CheckEmpty(para[1]),
> +				     EmptyString(para[2]) ? "" : " ", CheckEmpty(para[2]),
> +				     EmptyString(para[3]) ? "" : " ", CheckEmpty(para[3]));
>  	}
>  
>  	if(!joins)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: spaces2.diff
Type: text/x-diff
Size: 1766 bytes
Desc: not available
URL: <http://lists.ratbox.org/pipermail/ircd-ratbox/attachments/20160921/aba54033/attachment.diff>


More information about the ircd-ratbox mailing list