Subject: kern/7761: getcwd() fails mysteriously
To: None <gnats-bugs@gnats.netbsd.org>
From: Lennart Augustsson <augustss@augustsson.net>
List: netbsd-bugs
Date: 06/11/1999 10:22:46
>Number:         7761
>Category:       kern
>Synopsis:       getcwd() fails mysteriously
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 11 10:05:01 1999
>Last-Modified:
>Originator:     Lennart Augustsson
>Organization:
>Release:        NetBSD 1.4
>Environment:
System: NetBSD calvin 1.4 NetBSD 1.4 (CALVIN) #0: Sun May 9 18:41:36 CEST 1999 augustss@calvin:/usr/src/sys/arch/i386/compile/CALVIN i386


>Description:
	If the size argument to getcwd() is large enough the call fails
	with ERANGE.  From what I can tell from the man page this is
	wrong, and totally unintuitive.
	Furthermore, it used to work before getcwd() went into the kernel.
>How-To-Repeat:
	Run the following program.  With a smaller b (e.g. 1000) it works.

#include <stdio.h>
#include <unistd.h>
#include <err.h>

char b[10000];

main()
{
	char *r;
	r = getcwd(b, sizeof b);
	if (r == 0)
		err(1, 0);
	printf("path = '%s'\n", b);
}

>Fix:
	Dunno.
>Audit-Trail:
>Unformatted: