All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Jeff King <peff@peff.net>
Cc: Stefan Beller <sbeller@google.com>,
	Zenobiusz Kunegunda <zenobiusz.kunegunda@interia.pl>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |
Date: Fri, 17 Mar 2017 23:50:09 +0100	[thread overview]
Message-ID: <d27d4fd1-8069-ec53-df3f-c3e176f83f16@web.de> (raw)
In-Reply-To: <20170317222902.isndsmzy43btxh4i@sigill.intra.peff.net>

Am 17.03.2017 um 23:29 schrieb Jeff King:
> On Fri, Mar 17, 2017 at 10:07:18PM +0100, René Scharfe wrote:
>
>>>   As  an extension to the POSIX.1-2001 standard, Linux (libc4, libc5,
>>> glibc) getcwd()
>>>   allocates the buffer dynamically using malloc(3) if buf is NULL.  In
>>> this case, the
>>>   allocated buffer has the length size unless size is zero, when buf
>>> is allocated as big
>>>   as necessary.  The caller should free(3) the returned buffer.
>>>
>>> This sounds specific to Linux (though I am reading Linux man pages,
>>> which claim this; Also it seems I might have misread it as it also states
>>> "The pathname is returned as the function result and via the
>>> argument buf, if present.").
>>
>> I'm only interested in FreeBSD for now, as that's the platform Zenobiusz
>> reported the issue on and I haven't been able to reproduce it, so this is
>> still a bit exploratory, but hopefully getting closer.  This extension is
>> used in the first version of pwd(1) in FreeBSD's repo, comitted 1994-05-26,
>> so it was supported there basically forever.
>>
>> The oldest version I found that's using the extention is NetBSD's pwd(1),
>> which was committed 1993-03-21 and carries a SCCS timestamp of 1991-02-20.
>> Visual Studio .NET 2003 supports it as well.
>
> My big question is what happens on other platforms when they see a NULL
> (but 0-sized) buffer. Any reasonable implementation would just return
> ERANGE and we'd fall back to the existing code. But we often have to deal with unreasonable ones.
>
> So do we need a "my OS understands getcwd(NULL)" build knob?

POSIX specifies the behavior in this case as unspecified.  An 
implementation could offer a different extension, and e.g. return a 
pointer to a static buffer.  So the answer would probably be "yes" if 
this was a patch meant for public consumption.  For now it's only 
compatible with BSDs, Windows, MacOSX, Linux. :)

René

  reply	other threads:[~2017-03-17 23:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06 16:10 fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 | Zenobiusz Kunegunda
2017-03-08 17:36 ` René Scharfe
2017-03-09 11:01   ` Zenobiusz Kunegunda
2017-03-11 21:17     ` René Scharfe
2017-03-13 12:23       ` Zenobiusz Kunegunda
2017-03-13 17:31         ` René Scharfe
2017-03-14 15:25           ` Zenobiusz Kunegunda
2017-03-13 13:23       ` Zenobiusz Kunegunda
2017-03-13 21:31         ` René Scharfe
2017-03-14  7:44           ` Zenobiusz Kunegunda
2017-03-14 17:59             ` René Scharfe
2017-03-15  9:44               ` Zenobiusz Kunegunda
2017-03-15 21:30                 ` René Scharfe
2017-03-17 19:34                   ` René Scharfe
2017-03-17 19:45                     ` Stefan Beller
2017-03-17 21:07                       ` René Scharfe
2017-03-17 22:29                         ` Jeff King
2017-03-17 22:50                           ` René Scharfe [this message]
2017-03-21 13:29                         ` Zenobiusz Kunegunda
2017-03-21 19:04                           ` René Scharfe
2017-03-22  8:30                             ` Zenobiusz Kunegunda
2017-03-21 10:08                   ` Zenobiusz Kunegunda
2017-03-09 11:11   ` Zenobiusz Kunegunda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d27d4fd1-8069-ec53-df3f-c3e176f83f16@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    --cc=zenobiusz.kunegunda@interia.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.