Date: Tue, 16 Oct 2001 14:59:09 -0700 From: "Chad R. Larson" <chad@DCFinc.com> To: Dimitry Andric <dim@xs4all.nl> Cc: Nate Williams <nate@yogotech.com>, freebsd-stable@FreeBSD.ORG Subject: Re: setenv() cores with NULL value [was Re: Gdm proplem on 4.4] Message-ID: <20011016145909.B23454@freeway.dcfinc.com> In-Reply-To: <441356059.20011016201751@xs4all.nl>; from dim@xs4all.nl on Tue, Oct 16, 2001 at 08:17:51PM %2B0200 References: <200110160353.f9G3rO728525@harmony.village.org> <Pine.LNX.4.33.0110152249220.8479-100000@organ.cs.byu.edu> <20011016013834.E293@blossom.cjclark.org> <200110161002.f9GA2CA08544@shalimar.net.au> <15308.25432.608079.646993@nomad.yogotech.com> <441356059.20011016201751@xs4all.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 16, 2001 at 08:17:51PM +0200, Dimitry Andric wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 2001-10-16 at 18:42:00 Nate Williams wrote:
> 
> NW> printf("%s", "");
> NW> printf("%s", NULL);
> 
> NW> The first will work, the second will dump core.
> 
> Nope, it will print the string "(null)", as you can see in
> /usr/src/lib/libc/stdio/vfprintf.c, around line 673:
> 
>         case 's':
>                 if ((cp = GETARG(char *)) == NULL)
>                         cp = "(null)";
> 
> Almost any printf I've ever seen does the same.
Yes, but that is a function of printf(3), not of dereferencing NULL
pointers.  Modify slightly:
    /* dereference a null pointer */
    #define NULL 0
    main()
    {
	char	*foo; 
	static int	bar;
	foo = "junk";
	bar = *foo;
	foo = NULL;
	bar = *foo;
    }
	-crl
--
Chad R. Larson (CRL15)   602-953-1392   Brother, can you paradigm?
chad@dcfinc.com         chad@larsons.org          larson1@home.com
DCF, Inc. - 14623 North 49th Place, Scottsdale, Arizona 85254-2207
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011016145909.B23454>
