Date: Tue, 22 Oct 1996 12:26:47 +0200 (MESZ) From: "Hr.Ladavac" <lada@ws2301.gud.siemens.co.at> To: danny@panda.hilink.com.au (Daniel O'Callaghan) Cc: freebsd-hackers@freebsd.org Subject: Re: libc string routines don't check for NULL pointers Message-ID: <199610221026.AA287450007@ws2301.gud.siemens.co.at> In-Reply-To: <Pine.BSF.3.91.961022180422.548J-100000@panda.hilink.com.au> from "Daniel O'Callaghan" at Oct 22, 96 06:12:44 pm
next in thread | previous in thread | raw e-mail | index | archive | help
E-mail message from Daniel O'Callaghan contained: > > The string comparison (and other) routines in libc don't check for null > pointers being passed. This results in SEGVs if one or both of the > string pointers being passed is NULL. I can see a religious debate here, > but I'm going to raise the issue: Should str*cmp() handle NULL arguments. > > I have made the very simple change necessary to strcmp() for it to return > > 0 - strings are the same, or pointers are both NULL > < 0 - s1 < s2, or s1 == NULL > > 0 - s1 > s2 or s2 == NULL > > I'd like to see my changes made to libc, but what do others think - > should it be just "the programmer's stupid fault" if (s)he passes a NULL > pointer to these routines, or should the routines handle NULL? See the archives. Take a look at comp.lang.c FAQ as well. The general opinion is that 'char *a = 0;' is not a valid string; rather, it's a null-pointer, dereferencing of which is not allowed. I.e. the str* functions behave properly--"driver's fault" /Marino > > Danny >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610221026.AA287450007>