From tst@vulture.cs.mci.com  Tue Jan 28 23:33:51 1997
Received: from vulture.cs.mci.com ([166.41.208.13])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id XAA15941
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 28 Jan 1997 23:33:49 -0800 (PST)
Received: (from tst@localhost) by vulture.cs.mci.com (8.8.2/8.8.2) id AAA02051; Wed, 29 Jan 1997 00:26:56 -0700 (MST)
Message-Id: <199701290726.AAA02051@vulture.cs.mci.com>
Date: Wed, 29 Jan 1997 00:26:56 -0700 (MST)
From: Thomas S Traylor <tst@vulture.cs.mci.com>
Reply-To: Thomas.Traylor@mci.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: strdup will cause you app to core if passed a NULL string
X-Send-Pr-Version: 3.2

>Number:         2610
>Category:       gnu
>Synopsis:       strdup will cause you app to core if passed a NULL string
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 28 23:40:01 PST 1997
>Closed-Date:    Wed Jan 29 06:29:31 PST 1997
>Last-Modified:  Wed Jan 29 06:32:28 PST 1997
>Originator:     Thomas S Traylor
>Release:        FreeBSD 2.2-ALPHA i386
>Organization:
>Environment:

	Normal user environment.

>Description:

	The library function strdup does not handle a NULL string being
	passed to it. When you do the application cores.

>How-To-Repeat:

	Pass strdup a NULL string.

>Fix:
	
	Have strdup check for a NULL string and then return a NULL string.

>Release-Note:
>Audit-Trail:

From: j@uriah.heep.sax.de (J Wunsch)
To: Thomas.Traylor@mci.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/2610: strdup will cause you app to core if passed a NULL string
Date: Wed, 29 Jan 1997 10:05:36 +0100

 As Thomas S Traylor wrote:
 
 > >Number:         2610
 > >Category:       gnu
 
 Well, `gnu' is the wrong category, but nevermind.
 
 > 	The library function strdup does not handle a NULL string being
 > 	passed to it. When you do the application cores.
 
 Then don't do it.  It's not supposed to `duplicate' a NULL pointer, i
 think.  What would you exect from it?  Another NULL pointer?  How do
 you distinguish it from ``Out of memory''?
 
 Neither of the strxxx() functions accept NULL pointers, so i won't see
 a reason for strdup().
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Wed Jan 29 06:29:31 PST 1997 
State-Changed-Why:  
I don't believe that strdup() is supposed to do anything else when 
receiving a NULL argument, and returning NULL would cause the error 
to be indistinguishable from "out of memory", which is what anyone 
checking the return value of strdup() is going to flag in their failure 
case.  Just as with other routines like strcpy() core when getting 
NULL (and their behavior is mandated by the ISO 9899 spec), so should 
I believe strdup(). 
>Unformatted:
