From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 23 10:05:36 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D859106574E for ; Wed, 23 Apr 2008 10:05:36 +0000 (UTC) (envelope-from numisemis@yahoo.com) Received: from web36602.mail.mud.yahoo.com (web36602.mail.mud.yahoo.com [209.191.85.19]) by mx1.freebsd.org (Postfix) with SMTP id 07F4E8FC31 for ; Wed, 23 Apr 2008 10:05:35 +0000 (UTC) (envelope-from numisemis@yahoo.com) Received: (qmail 1979 invoked by uid 60001); 23 Apr 2008 09:38:54 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=DSn+NWXmG9kIhnVcFAcqvKbFPKPOexu1X7/53Zn9DJkseABNFtyhwVEAgj3QenGeIRiwOfTy7t0REAdDfqB8MXX3NixgOUOK/zBHlpfBc5NsudKGFsK3I+dVTrassHJXzxO2utHGhFMLAtS+f7G6JasAF0hkeioqlJ09RuDe3Eo=; X-YMail-OSG: fV0Vqp8VM1lc39bgwP_KY4UeRs_pdJ4chWliwoZcxaNuUfDJjqEtYGcDFsjiBoS4_DTPmpifq275EVRltg41jcoBGP.YnSZruPUbrQqifVRDgioJlbIWvsRL9aA- Received: from [85.10.55.94] by web36602.mail.mud.yahoo.com via HTTP; Wed, 23 Apr 2008 02:38:54 PDT Date: Wed, 23 Apr 2008 02:38:54 -0700 (PDT) From: Simun Mikecin To: mwm-keyword-freebsdhackers2.e313df@mired.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <251738.1147.qm@web36602.mail.mud.yahoo.com> X-Mailman-Approved-At: Wed, 23 Apr 2008 11:20:37 +0000 Cc: hackers@freebsd.org Subject: Re: strdup(NULL) supposed to create SIGSEGV? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2008 10:05:36 -0000 >Yes, it's supposed to segfault. Check out what, say, strcpy does if >you ask it to copy a NULL pointer. And this is an improvement from the >bad old days, when they would happily walk through memory starting at >0..... >Besides, errno is used to signal errors from system calls. strdup >isn't a system call, it's a library function (says so at the top of >the man page). >Do you have examples of systems where strdup doesn't behave this way? According to Open Group strdup should return NULL and set errno. Look at: http://www.opengroup.org/onlinepubs/009695399/functions/strdup.html There is no valid argument for doing segfault instead of above behavior. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ