Re: [dev] [sic] null pointer in printf

From: Kris Maglione <maglione.k_AT_gmail.com>
Date: Mon, 24 May 2010 07:51:48 -0400

On Mon, 24 May 2010 10:02:47 +0200
Premysl Hruby <dfenze_AT_gmail.com> wrote:

> Hi,
>
> in sic, if you use cmd ":m something" it will use null pointer as %s
> in printf (in function privmsg), which is obviously bad idea
> (segfault or, as in case of glibc it send unnecessary string "(null)".

I haven't come across a printf that segfaults when passed a null
pointer for %s. All of the BSDs handle it, along with uClibc and
dietlibc, and I seem to recall that Solaris/SunOS does as well.

> For fix, see patch:
>
> diff -r 503b48b13a77 sic.c
> --- a/sic.c Tue Jul 29 19:22:08 2008 +0100
> +++ b/sic.c Mon May 24 09:58:32 2010 +0200
> @@ -77,8 +77,9 @@
> else if(!strncmp(msg + 1, "l ", 2))
> snprintf(bufout, sizeof bufout, "PART %s :sic - 250
> LOC are too much!\r\n", msg + 3); else if(!strncmp(msg + 1, "m ", 2))
> {
> - if((p = strchr(msg + 3, ' ')))
> - *(p++) = 0;
> + if (!(p = strchr(msg + 3, ' ')))
> + return;
> + *(p++) = 0;
> privmsg(msg + 3, p);
> return;
> }

What version of sic are you using? The current version doesn't have
that code anymore.

-- 
Kris Maglione
FAITH, n.  Belief without evidence in what is told by one who speaks
without knowledge, of things without parallel.
	--Ambrose Bierce
Received on Mon May 24 2010 - 11:51:48 UTC

This archive was generated by hypermail 2.2.0 : Mon May 24 2010 - 12:00:03 UTC