IRC correctness checks

Ethan Blanton elb at pidgin.im
Wed Jan 15 20:38:15 EST 2014


Tomasz Wasilczyk spake unto us the following wisdom:
> W dniu 15.01.2014 03:57, Ethan Blanton pisze:
> >if (!args || !args[0] || !args[1])
> >     return;
> 
> I've implemented the new "feature" for parser (and committed to
> private repo). But when I started figuring out the required
> parameter counts, I realized that in most (every?) cases we need a
> PurpleConnection object, so msgs.c has a lot of checks for gc being
> not NULL.

I just looked at this, anad it looks like most of the uses of gc are
for purple_notify_*.  There are a handful of serv_* and blist
functions, but they're in the minority.  If purple_notify_* fails
gracefully when passed a gc of NULL, we might want to check the gc
only when it's needed for something else.

That said, it looks like we expect it to exist almost everywhere.
Even irc_msg_quit uses it blindly, which is a place where I might
expect it to not exist any more.

> Can I safely assume, that (gc != NULL) is required for *all* IRC
> messages, to get rid of these checks? Also, to simplify the code a
> bit, PurpleConnection object could be passed to the callback, just
> like irc_conn struct is.

Probably, yeah.  I don't know about passing gc, those functions
already have a lot of arguments.  I'm not violently opposed, however.

> Moreover, I'm not sure if PURPLE_CONNECTION_IS_CONNECTED shouldn't
> be checked also.

I think only in a very few places.  The fact that we're receiving a
message means that if the connection is disconnected, it is newly so,
and we might be clearing a backlog of incoming data that it makes
sense to flush anyway.

Ethan


More information about the security mailing list