delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/10/15:10:31

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <20001010185300.23932.qmail@web109.yahoomail.com>
Date: Tue, 10 Oct 2000 11:53:00 -0700 (PDT)
From: Earnie Boyd <earnie_boyd AT yahoo DOT com>
Subject: Re: Two snapshot bugs
To: cygwin AT sources DOT redhat DOT com
MIME-Version: 1.0

--- Chris Faylor <cgf AT cygnus DOT com> wrote:
> On Tue, Oct 10, 2000 at 06:08:53PM +0100, Fifer, Eric wrote:
> >+ getcwd() seems to be busted:
> >
> >	#include <stdio.h>
> >	main() { printf("getcwd=%s\n", getcwd(NULL, 0)); }
> >
> >  produces:
> >
> >	getcwd=(null)
> 
> In any description of getcwd that I"ve found, specifying '0' as the size
> means that you allocate a zero length buffer.
> 
> The linux man page says this:
> 
>        As  an  extension  to the POSIX.1 standard, getcwd() allo-
>        cates the buffer dynamically using malloc() if buf is NULL
>        on  call.   In  this  case,  the  allocated buffer has the
>        length size unless size is less than  zero,  when  buf  is
>        allocated  as  big  as  necessary.   It  is possible (and,
>        indeed, advisable) to free() the buffers if they have been
>        obtained this way.
> 
> So 'getcwd (NULL, -1)' should return something but 'getcwd (NULL, 0)', IMO,
> should not.
> 

And the "Single UNIX Specification" as copyrighted by the Open Group doesn't
even give it that much freedom.  Gives an EINVAL error for size 0 and says that
if buf is a NULL pointer then the result is undefined.  Reference:
http://www.opennc.org/onlinepubs/7908799/xsh/getcwd.html

Cheers,

=====
Earnie Boyd
mailto:earnie_boyd AT yahoo DOT com

---         <http://earniesystems.safeshopper.com>         ---
--- Cygwin: POSIX on Windows <http://gw32.freeyellow.com/> ---
---   Minimalist GNU for Windows <http://www.mingw.org/>   ---

__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019