Home | History | Annotate | Download | only in gen
History log of /src/lib/libc/gen/getcwd.c
RevisionDateAuthorComments
 1.53  21-Jun-2012  enami All error path must go through the free function call after an
allocation of resolved path might succeeded.
 1.52  21-Jun-2012  christos PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.51  13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.50  21-Feb-2011  joerg branches: 1.50.4; 1.50.6; 1.50.10;
Redo the SSP wrappers to be transparent on the resulting object files.
This works by having the inline wrapper calling a second function which
uses renaming to output the correct function name.
 1.49  16-Feb-2011  tron Fix build with SSP enabled.
 1.48  15-Feb-2011  christos Fix non-fortify build.
 1.47  20-Jan-2011  christos provide a _sys_getcwd() entry like all the rest of the system calls to be
used by SSP.
 1.46  01-Jan-2010  dholland branches: 1.46.2;
POSIX says realpath(NULL, foo) is supposed to yield EINVAL rather than
being allowed to crash. Go figure. Closes PR lib/42559 from Stathis Kamperis.
 1.45  26-Oct-2007  christos make _FORTIFY_SOURCE play nicely with lint
 1.44  03-Jun-2007  christos branches: 1.44.4;
Make these work with _FORTIFY_SOURCE, by overriding the fortified definitions
 1.43  17-Mar-2006  christos Appease Coverity CID 2527; not a bug.
 1.42  31-Dec-2005  elad Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.41  22-Dec-2005  elad Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.

This is what broke systrace's filename normalization.

Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.40  13-Aug-2005  elad Make this compile again (remove unused serrno).
Noted by uwe@.
 1.39  13-Aug-2005  elad Don't allow last path element to be nonexistant.
 1.38  05-Jul-2005  enami Fixes to previous:
- Don't handle single and multiple slashes differently.
- A symlink to a directory can be appear in the middle of path. Don't
reject it.
 1.37  04-Jul-2005  elad Make realpath(3) work correctly.

The current code resolves paths like `/foo/bar/', `/foo/bar/./', and
`/foo/bar/../', even if `bar' is a regular file and not a directory.

Reviewed by cube@.
 1.36  30-Jan-2005  enami branches: 1.36.2;
- Modify realpath() not to alter process wide state current working
directory. Strategy from FreeBSD. Addess PR#28986.
- Make realpath() to return an error when null string is passed or
the last component is symlink to null string. The kernel lookup
routine returns an error if such path are passed.
 1.35  23-Jan-2005  enami - Remove macros used only by old getcwd() implementation.
- Fix memory leak on error. (I guess the loop isn't necessary but
it is different matter).
- Remove knowledge about old malloc implementation.
 1.34  06-Jan-2005  simonb Remove the old userland version of getcwd(): it's been #ifdef'd out
since 1999 when we switched to a (faster) system call based getcwd(),
and as shown recently has had some buffer size problems anyway (although
they have since been fixed).
 1.33  06-Jan-2005  christos Fix handling of memory allocation. From OpenBSD.
 1.32  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.31  03-Aug-2003  itojun be more pedantic to strlcpy/strcat errors
 1.30  03-Aug-2003  itojun use strlcat for safety
 1.29  03-Aug-2003  itojun fix off-by-one error in realpath()
 1.28  17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.27  17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.26  19-Oct-2002  provos readlink(2) does not NUL-terminate, use with sizeof (buf-1).
from deraadt@openbsd.org; approved thorpej.
 1.25  16-Apr-2002  groo branches: 1.25.2;
botched strncpy -> strlcpy
from xs@kittenz.org
 1.24  22-Jan-2000  mycroft branches: 1.24.4; 1.24.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.23  20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.22  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.21  10-Aug-1999  fvdl Keep track of the number of encountered symlinks and fail with ELOOP
if they exceed MAXSYMLINKS.
 1.20  11-Jul-1999  sommerfeld Avoid infinite loop if pathname is longer than the maximum the kernel
is willing to return from getcwd().
(this can only happen in -current).
 1.19  11-Jun-1999  christos make this compile under linux
 1.18  03-May-1999  christos int -> size_t problems, change do { } while (0) to for (;;)
 1.17  26-Mar-1999  sommerfe move __getcwd prototypes to libc-private header file.

XXX duplicate the prototype in getcwd regression test (which needs to
call the syscall directly for reasonably complete testing).
 1.16  26-Mar-1999  sommerfe Use __getcwd() system call in getcwd() unless OLD_GETCWD is defined
 1.15  06-Nov-1998  christos port to svr4.
 1.14  26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.13  10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.12  14-Mar-1998  lukem backout parts of the lite2 merge; it causes undesirable lossage:
* $PWD was used if it appeared ``correct''. this `enhancment' was
not documented in getcwd(3), and caused problems for pwd(1) (which
uses getcwd(3)), and in turn <bsd.obj.mk> (which uses pwd) when $PWD
is set to the logical path instead of the real path (e.g, symlink
/usr/src -> /z/NetBSD-current/src).
[$PWD is set to the logical path by tcsh(1) with set symlinks=expand]
* as getcwd() without the $PWD code is just a wrapper to getcwd_physical(),
rename the latter to the latter. hack realpath() to use the getcwd().

yet another case of `it was a good idea, but...'
 1.11  26-Feb-1998  perry trivial changes to reduce lint complaints
 1.10  03-Feb-1998  perry remove obsolete register declarations
 1.9  02-Feb-1998  perry add some fixes to realpath() that were in the old realpath.c
 1.8  02-Feb-1998  perry merge/update to lite-2
 1.7  21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6  13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.5  16-Jun-1995  jtc branches: 1.5.4;
Don't cast void functions to void.
 1.4  27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.3  26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2  30-Jul-1993  mycroft Add even more RCS frobs.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  02-Feb-1998  perry import lite-2
 1.1.1.2  25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1  02-May-1995  jtc #include "namespace.h"
 1.5.4.2  19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.5.4.1  16-Sep-1996  jtc snapshot namespace cleanup
 1.24.6.3  10-Dec-2002  thorpej Sync with HEAD.
 1.24.6.2  11-Nov-2002  nathanw Catch up to -current
 1.24.6.1  25-Apr-2002  nathanw Catch up to -current.
 1.24.4.3  12-May-2004  jmc Pullup rev 1.26 (requested by kleink in ticket #146)

readlink(2) does not NUL-terminate, use with sizeof (buf-1).
 1.24.4.2  05-Aug-2003  msaitoh Pull up revision 1.29 (requested by itojun in ticket #61):
Fix NetBSD SA 2003-11.
Fix off-by-one error in realpath().
 1.24.4.1  17-Apr-2002  he Pull up revision 1.25 (requested by groo):
Replace an instance of erroneous usage of strncpy() with strlcpy().
 1.25.2.2  11-May-2004  tron Pull up revision 1.26 (requested by kleink in ticket #1687):
readlink(2) does not NUL-terminate, use with sizeof (buf-1).
from deraadt@openbsd.org; approved thorpej.
 1.25.2.1  04-Aug-2003  grant Pull up revision 1.29 (requested by itojun in ticket #1394):

fix off-by-one error in realpath()
 1.36.2.3  01-Jan-2006  riz Pull up following revision(s) (requested by elad in ticket #1077):
lib/libc/gen/getcwd.c: revision 1.42
Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.36.2.2  29-Dec-2005  riz Pull up following revision(s) (requested by elad in ticket #1068):
lib/libc/gen/getcwd.c: revision 1.41
Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.
This is what broke systrace's filename normalization.
Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.36.2.1  14-Aug-2005  riz branches: 1.36.2.1.2;
Pull up revisions 1.37-1.40 (requested by elad in ticket #648):
1.37:
Make realpath(3) work correctly.
The current code resolves paths like `/foo/bar/', `/foo/bar/./', and
`/foo/bar/../', even if `bar' is a regular file and not a directory.
Reviewed by cube@.

1.38:
Fixes to previous:
- Don't handle single and multiple slashes differently.
- A symlink to a directory can be appear in the middle of path. Don't
reject it.

1.39:
Don't allow last path element to be nonexistant.

1.40:
Make this compile again (remove unused serrno).
Noted by uwe@.
 1.36.2.1.2.2  01-Jan-2006  riz Pull up following revision(s) (requested by elad in ticket #1077):
lib/libc/gen/getcwd.c: revision 1.42
Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.36.2.1.2.1  29-Dec-2005  riz Pull up following revision(s) (requested by elad in ticket #1068):
lib/libc/gen/getcwd.c: revision 1.41
Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.
This is what broke systrace's filename normalization.
Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.44.4.1  06-Nov-2007  matt sync with HEAD
 1.46.2.3  05-Mar-2011  bouyer Sync with HEAD
 1.46.2.2  17-Feb-2011  bouyer Sync with HEAD
 1.46.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.50.10.1  20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.50.6.1  20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.50.4.2  30-Oct-2012  yamt sync with head
 1.50.4.1  17-Apr-2012  yamt sync with head

RSS XML Feed