*BSD News Article 45243


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!taligent!uunet!news.mathworks.com!zombie.ncsc.mil!admii!cmcl2!newsserv.cs.sunysb.edu!starkhome.cs.sunysb.edu!localhost!gene
From: gene@starkhome.cs.sunysb.edu (Gene Stark)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Major strcmp bug under BSD 2.0?
Date: 30 May 95 22:34:49
Organization: Gene Stark's home system
Lines: 15
Message-ID: <GENE.95May30223449@starkhome.cs.sunysb.edu>
References: <3qfn52$188j@troy.la.locus.com>
NNTP-Posting-Host: localhost.cs.sunysb.edu
In-reply-to: sassan@locus.com's message of 30 May 1995 18:11:46 GMT

>Am I imagining things or is there a bug in BSD 2.0's strcmp() function?
>If either of the string parameters is NULL the program core dumps.
>Isn't this a major bug? (Making the OS pretty much useless). Is there 
>a simple fix for this ? 

No, it is an example of a subroutine that only works under conditions
that must be ensured by the caller.  This is probably done for efficiency
reasons: if it always checks if its arguments are NULL, then you pay
every time, even if as a clever programmer you are able to guarantee
without checking that you always pass non-NULL arguments.

It hardly makes the entire OS useless...

							- Gene Stark