From owner-freebsd-hackers Tue Oct 22 01:13:00 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id BAA10524 for hackers-outgoing; Tue, 22 Oct 1996 01:13:00 -0700 (PDT) Received: from panda.hilink.com.au (panda.hilink.com.au [203.2.144.5]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id BAA10519 for ; Tue, 22 Oct 1996 01:12:52 -0700 (PDT) Received: (from danny@localhost) by panda.hilink.com.au (8.7.6/8.7.3) id SAA06184; Tue, 22 Oct 1996 18:12:46 +1000 (EST) Date: Tue, 22 Oct 1996 18:12:44 +1000 (EST) From: "Daniel O'Callaghan" To: freebsd-hackers@freebsd.org Subject: libc string routines don't check for NULL pointers Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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? Danny