summaryrefslogtreecommitdiff
path: root/lib/canonicalize.c
Commit message (Collapse)AuthorAgeFilesLines
* canonicalize: remove NARROW_ADDRESSES optimizationPaul Eggert2021-01-011-5/+1
| | | | | | | * lib/canonicalize-lgpl.c, lib/canonicalize.c (NARROW_ADDRESSES): Remove, and remove all uses, as the optimization is arguably not worth the extra complexity. Suggested by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121203.html
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* canonicalize: fix size overflow treatmentPaul Eggert2020-12-291-7/+2
| | | | | | | | | | | | | | This also has some minor cleanups. * lib/canonicalize-lgpl.c, lib/canonicalize.c: No need to include stddef.h, since the code no longer refers directly to ptrdiff_t. * lib/canonicalize-lgpl.c (realpath_stk): * lib/canonicalize.c (canonicalize_filename_mode_stk): Treat size overflow like other out-of-memory. * lib/canonicalize.c: No need to include stdlib.h, since the code no longer refers to stdlib.h functions (other than those that canonicalize.h must declare). * lib/canonicalize.c (canonicalize_filename_mode_stk): Do not bother terminating the string result on error.
* canonicalize: fix ptrdiff_t overflow bugPaul Eggert2020-12-291-1/+11
| | | | | | | | | | | | | | Problem reported by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121182.html * lib/canonicalize-lgpl.c, lib/canonicalize.c: Include intprops.h. (NARROW_ADDRESSES): New constant. * lib/canonicalize-lgpl.c (realpath_stk):m * lib/canonicalize.c (canonicalize_filename_mode_stk): Work even if strlen (END) does not fit in idx_t, or if adding N to it overflows. * modules/canonicalize, modules/canonicalize-lgpl (Depends-on): Add intprops.
* faccessat: revert recent EOVERFLOW changePaul Eggert2020-12-281-8/+2
| | | | | | | | | | | | | | | I misunderstood the glibc source code. Deduced from Adhemerval Zanella’s proposed glibc patch in: https://sourceware.org/pipermail/libc-alpha/2020-December/121131.html * doc/posix-functions/faccessat.texi: It is not a problem. * lib/canonicalize-lgpl.c, lib/canonicalize.c, lib/faccessat.c: (FACCESSAT_NEVER_OVERFLOWS): Remove. All uses removed. * lib/faccessat.c: Revert to simpler version now that LSTAT_FOLLOWS_SLASHED_SYMLINK must be false. * m4/faccessat.m4 (gl_FUNC_FACCESSAT_EOVERFLOW): Remove. All uses removed. * modules/canonicalize, modules/canonicalize-lgpl (Files): Remove m4/faccessat.m4.
* canonicalize: simplify via scratch_buffer_dupfreePaul Eggert2020-12-281-5/+4
| | | | | | | | | | | * config/srclist.txt: Adjust accordingly. * lib/canonicalize-lgpl.c (realpath_stk): * lib/canonicalize.c (canonicalize_filename_mode_stk): Simplify by using scratch_buffer_dupfree. * lib/malloc/scratch_buffer.h (scratch_buffer_dupfree): New function. * lib/malloc/scratch_buffer_dupfree.c: New file. * modules/scratch_buffer (Files, Depends-on): Add malloc/scratch_buffer_dupfree.c.
* canonicalize, canonicalize-lgpl: remove lintPaul Eggert2020-12-241-5/+11
| | | | | | | | | | | | | | Pacify GCC. Some of these problems were reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2020-12/msg00217.html * lib/canonicalize-lgpl.c, lib/canonicalize.c: Sort shared include directives, for consistency. (IF_LINT): New macro. (suffix_requires_dir_check): Mark with _GL_ATTRIBUTE_PURE. * lib/canonicalize-lgpl.c (GCC_LINT, _GL_ATTRIBUTE_PURE) [_LIBC]: New macros. (realpath_stk): Suppress bogus -Wmaybe-uninitialized warning. * lib/canonicalize.c (canonicalize_filename_mode_stk): Omit unused local. Suppress bogus -Wmaybe-uninitialized warning.
* canonicalize: prefer faccessat to statPaul Eggert2020-12-241-12/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A proper faccessat doesn't have the EOVERFLOW problem, and can be more efficient as it needn't gather data from the filesystem to fill in struct stat. So use stat only if faccessat is absent, or when checking for symlink loops in canonicalize.c. * lib/canonicalize-lgpl.c, lib/canonicalize.c: Include fcntl.h, for AT_EACCESS. (FACCESSAT_NEVER_EOVERFLOWS): Default to false. (file_accessible): New function, based on faccessat but with a fallback to stat and with an EOVERFLOW workaround. (dir_check): Use it. (dir_suffix): New static constant. * lib/canonicalize-lgpl.c (FACCESSAT_NEVER_EOVERFLOWS) [_LIBC]: Use __ASSUME_FACCESSAT2 to set FACCESSAT_NEVER_EOVERFLOWS (__faccessat) [!_LIBC]: Define. (realpath_stk): Use dir_suffix now. * lib/canonicalize.c (canonicalize_filename_mode_stk): If logical, don't check each component's existence; just check at the end, as that's enough. * m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE) (gl_CANONICALIZE_LGPL_SEPARATE): Require gl_FUNC_FACCESSAT_EOVERFLOW, gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, and check for faccessat. (gl_CANONICALIZE_LGPL_SEPARATE): Do not check for readlink, as the code does not use HAVE_READLINK. * modules/canonicalize, modules/canonicalize-lgpl (Files): Add m4/faccessat.m4, m4/lstat.m4. (Depends-on): Add fcntl-lh.
* canonicalize, canonicalize-lgpl: fix symlink bugPaul Eggert2020-12-241-18/+63
| | | | | | | | | | | | | | | | | | | Problem reported by Adhemerval Zanella in: https://lists.gnu.org/r/bug-gnulib/2020-12/msg00155.html * lib/canonicalize-lgpl.c, lib/canonicalize.c: (suffix_requires_dir_check, dir_check): New functions. (GCC_BOGUS_WRETURN_LOCAL_ADDR): New macro, to put the diagnostic closer to the related GCC diagnostics. * lib/canonicalize-lgpl.c (realpath_stk): * lib/canonicalize.c (canonicalize_file_mode_stk): Use them to fix a bug with .../symlink-to-regular-file/ etc. * lib/canonicalize-lgpl.c (__stat) [!_LIBC]: New macro. (realpath_stk): New function, with the contents of the old __realpath and a new scratch buffer arg. This is needed to pacify GCC 10.1, as canonicalize.c is already doing. (__realpath): Use it. * tests/test-canonicalize-lgpl.c, tests/test-canonicalize.c: Add test cases for the bugs.
* canonicalize: omit second readlink when not neededPaul Eggert2020-12-171-24/+8
| | | | | | * lib/canonicalize.c (canonicalize_filename_mode_stk): Omit second readlink when (can_exist != CAN_MISSING && startlen != 0 && !logical). Simplify.
* canonicalize: remove arbitrary 8192-byte limitPaul Eggert2020-12-171-93/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove canonicalize.c’s arbitrary 8192-byte limit on platforms like GNU Hurd that do not define the PATH_MAX macro, and similarly for canonicalize-lgpl.c’s arbitrary 1024-byte limit. Do this by using scratch buffers. Lessen the number of differences between the two source files, to simplify this and future maintenance. * lib/canonicalize-lgpl.c (__realpath): * lib/canonicalize.c (canonicalize_filename_mode_stk): Use scratch buffers instead of malloc and malloca. This avoids the need for alloca, and avoids the need for malloc in most cases. * lib/canonicalize-lgpl.c, lib/canonicalize.c: Make these files easier to compare, e.g., by sorting include files and by switching to the GNU convention of calling file names "file names", not "path names". Include stdbool.h, scratch_buffer.h. * lib/canonicalize-lgpl.c (IDX_MAX) [_LIBC]: New macro. (malloca) [_LIBC]: Remove. [!_LIBC]: Do not include malloca.h. (get_path_max): New function, so that pathconf is called only in the rare and dubious case when when RESOLVED is not null and PATH_MAX is not defined. Invoke pathconf on "/" not the input file name, as we care about the longest file name starting from "/" (not from the input file name), and POSIX does not specify what pathconf does on a non-directory file anyway. If PATH_MAX is not defined, do not worry about overriding a path_max of 0, and do not let path_max exceed IDX_MAX. (__realpath): Remove an assumption that file name components cannot exceed 1024 bytes when PATH_MAX is not defined (wrong for the Hurd, presumably). When allocating the result, allocate it to just the right size; this costs nothing when the result is smaller than 1023 bytes, and for larger results it's probably worth the CPU to call realloc, as canonicalize.c already does. * lib/canonicalize.c: Include attribute.h. Do not include pathmax.h or xgetcwd.h. (PATH_MAX): Do not define, so file names longer than 8192 bytes work on platforms with no fixed limit. (canonicalize_filename_mode_stk): New function, with the content of the old canonicalize_filename_mode. Use getcwd instead of xgetcwd, and readlink instead of areadlink, since the scratch buffers now do memory management for us. Use rawmemchr instead of adding strlen. Use mempcpy instead of mempcpy + size. Assume free preserves errno. (canonicalize_filename_mode): Use it. * modules/canonicalize (Depends-on): Remove areadlink, pathmax, xgetcwd. Add attribute, free, getcwd, mempcpy, rawmemchr, scratch_buffer, stdbool, xalloc-die. * modules/canonicalize-lgpl (Depends-on): Remove alloca-opt, malloca, realloc-posix. Add scratch_buffer, stdbool.
* canonicalize: fix AIX test failuresPaul Eggert2020-12-131-15/+22
| | | | | | | | | | Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2020-12/msg00109.html * lib/canonicalize.c (canonicalize_filename_mode): When testing a file name ending in '/', use stat rather than readlink, so that it does the right thing on AIX. * modules/canonicalize (Depends-on): Add readlink, to pull in the recent changes in the Gnulib readlink module.
* idx: New module.Bruno Haible2020-12-031-11/+12
| | | | | | | | | | * lib/idx.h: New file. * modules/idx: New file. * lib/canonicalize-lgpl.c: Include idx.h. Use idx_t instead of ptrdiff_t. * lib/canonicalize.c: Likewise. * modules/canonicalize-lgpl (Depends-on): Add idx. * modules/canonicalize (Depends-on): Likewise.
* canonicalize: refactor can_mode flagPaul Eggert2020-12-021-11/+13
| | | | | | | * lib/canonicalize.c (MULTIPLE_BITS_SET): Remove, replacing with ... (multiple_bits_set): ... this new static function. Uses changed. (canonicalize_filename_mode): Refactor for clarity to avoid modifying the CAN_MODE argument.
* canonicalize: prefer signed integer typesPaul Eggert2020-12-021-10/+11
| | | | | | | * lib/canonicalize.c: Include stddef.h, for ptrdiff_t. (seen_triple, canonicalize_filename_mode): Prefer signed to unsigned types where either will do, as they avoid some glitches in comparisons and can trap on overflow when debugging.
* canonicalize: fix most of another EOVERFLOW issuePaul Eggert2020-12-021-2/+7
| | | | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): Do not call stat if fewer than 20 symlinks have been traversed. This avoids EOVERFLOW failure in the common case where there are not that many symlinks, while continuing to catch loops (or fail due to EOVERFLOW) in the unusual case when there are many symlinks to traverse.
* canonicalize: do not assume symlinks have st_inoPaul Eggert2020-12-021-21/+29
| | | | | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): When checking for loops, use st_dev and st_ino from the parent directory not from the symlink, as pre-2017 POSIX says these members are not reliable for symlinks. Couple this with START (the remaining file name to be resolved), not NAME (the whole file name with START as its suffix). * modules/canonicalize (Depends-on): Depend on stat, not lstat.
* canonicalize: fix EOVERFLOW bugPaul Eggert2020-12-021-38/+29
| | | | | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): When testing whether a directory entry is a symbolic link, or a directory or other, do not use lstat or stat or areadlink_with_size. Just use areadlink, as this suffices and it avoids the EOVERFLOW problem that lstat and stat have. * modules/canonicalize (Depends-on): Depend on areadlink instead of areadlink-with-size and stat.
* canonicalize: Add support for UNC file names on native Windows.Bruno Haible2020-09-211-2/+28
| | | | | | | | Reported and initial patch by Vaclav Slavik <vaclav@slavik.io> in <https://savannah.gnu.org/bugs/?59079>. * lib/canonicalize.c (canonicalize_filename_mode): For UNC file names, extend the prefix to include the server.
* canonicalize: fix pointer indexing bugsPaul Eggert2020-09-101-11/+8
| | | | | | | | | | Problem reported by Florian Weimer in: https://lists.gnu.org/r/bug-gnulib/2020-09/msg00025.html * lib/canonicalize-lgpl.c (__realpath): * lib/canonicalize.c (canonicalize_filename_mode): Do not generate a pointer past the end of the array. * lib/canonicalize.c (canonicalize_filename_mode): Do not use a pointer after passing it to realloc.
* Use module 'filename' instead of module 'dosname'.Bruno Haible2020-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/at-func.c: Include filename.h instead of dosname.h. * lib/unlinkat.c: Likewise. * modules/areadlinkat (Depends-on): Add filename. Remove dosname. * modules/areadlinkat-with-size (Depends-on): Likewise. * modules/faccessat (Depends-on): Likewise. * modules/fchmodat (Depends-on): Likewise. * modules/fchownat (Depends-on): Likewise. * modules/fstatat (Depends-on): Likewise. * modules/mkdirat (Depends-on): Likewise. * modules/mkfifoat (Depends-on): Likewise. * modules/readlinkat (Depends-on): Likewise. * modules/selinux-at (Depends-on): Likewise. * modules/symlinkat (Depends-on): Likewise. * modules/unlinkat (Depends-on): Likewise. * modules/utimensat (Depends-on): Likewise. * lib/at-func2.c: Include filename.h instead of dosname.h. * modules/linkat (Depends-on): Add filename. Remove dosname. * modules/renameatu (Depends-on): Likewise. * lib/canonicalize.c: Include filename.h instead of dosname.h. * lib/canonicalize-lgpl.c: Likewise. * modules/canonicalize (Depends-on): Add filename. * modules/canonicalize-lgpl (Depends-on): Likewise. * lib/dirname.h: Include filename.h instead of dosname.h. * modules/dirname-lgpl (Depends-on): Add filename. Remove dosname. * lib/fchdir.c: Include filename.h instead of dosname.h. * modules/fchdir (Depends-on): Add filename. Remove dosname. * lib/openat.c: Include filename.h instead of dosname.h. * modules/openat (Depends-on): Add filename. Remove dosname. * lib/rmdir.c: Include filename.h instead of dosname.h. * modules/rmdir (Depends-on): Add filename. Remove dosname. * lib/savewd.c: Include filename.h instead of dosname.h. * modules/savewd (Depends-on): Add filename. Remove dosname. * lib/unlink.c: Include filename.h instead of dosname.h. * modules/unlink (Depends-on): Add filename. Remove dosname. * modules/relocatable-prog-wrapper (Depends-on): Add filename. * lib/relocwrapper.c: Update comments. * modules/lstat (Depends-on): Remove dosname.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* canonicalize: fix EOVERFLOW commentaryPaul Eggert2017-07-301-0/+1
| | | | | | | Problem reported by Bruno Haible in: http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00147.html * lib/canonicalize.c (canonicalize_filename_mode): * lib/canonicalize-lgpl.c (__realpath): Fix comments.
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* canonicalize, canonicalize-lgpl: Microsoft Windows prefix fixesEli Zaretskii2012-12-101-3/+6
| | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): * lib/canonicalize-lgpl.c (__realpath): Recompute prefix_len after fetching the current directory. Don't overrun the beginning of rpath if there's no slashes after the MS-Windows drive letter.
* canonicalize, canonicalize-lgpl: support MS-Windows file namesEli Zaretskii2012-11-201-21/+47
| | | | | | | | | | | | | | | | See <http://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00074.html> for test cases, which it'd be nice to add at some point. * lib/canonicalize.c, lib/canonicalize-lgpl.c: Include dosname.h. * lib/canonicalize.c (canonicalize_filename_mode): * lib/canonicalize-lgpl.c (__realpath): Use FILE_SYSTEM_PREFIX_LEN instead of assuming that the first slash is at the beginning of the file name. Use ISSLASH, instead of a literal '/'. Use IS_ABSOLUTE_FILE_NAME instead of comparing the first character with '/'. Test for DOUBLE_SLASH_IS_DISTINCT_ROOT only if the file name does not begin with a drive letter. * lib/canonicalize.c (SLASHES): New macro. (canonicalize_filename_mode): Use SLASHES instead of a literal "/".
* canonicalize: fix C89 compilationPádraig Brady2012-10-141-2/+2
| | | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): Swap order of declarations so C89 is supported. Also remove the comment referencing mem allocation as the suggested feature could not be implemented as suggested. Reported by Michael Goffioul
* canonicalize: avoid uninitialized memory useEric Blake2012-02-041-5/+12
| | | | | | | | | | | | | | | | | When DOUBLE_SLASH_IS_DISTINCT_ROOT is non-zero, then we were reading the contents of rpath[1] even when we had never written anything there, which meant that "///" would usually canonicalize to "/" but sometimes to "//" if a '/' was leftover in the heap. This condition could also occur via 'ln -s / //some/path' and canonicalizing //some/path, where we rewind rpath but do not clear out the previous round. Platforms where "//" and "/" are equivalent do not suffer from this read-beyond-written bounds. * lib/canonicalize-lgpl.c (__realpath): Avoid possibility of random '/' left in dest. * lib/canonicalize.c (canonicalize_filename_mode): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
* canonicalize: fix // handlingEric Blake2012-02-041-5/+7
| | | | | | | | | | | | On Cygwin, and other platforms where // is detected as distinct from / at configure time, the canonicalize routines were incorrectly treating all instances of multiple leading slashes as //. See also coreutils bug http://debbugs.gnu.org/10472 * lib/canonicalize.c (canonicalize_filename_mode): Don't convert /// to //, since only // is special. Signed-off-by: Eric Blake <eblake@redhat.com>
* In commentary, do not use ` to quote.Paul Eggert2012-01-051-2/+2
|
* canonicalize: Tweak 2011-12-29 commit.Bruno Haible2012-01-031-1/+1
| | | | | * lib/canonicalize.c (canonicalize_filename_mode): Fix typo in comment. * lib/canonicalize.h (canonicalize_filename_mode): Update specification.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* canonicalize: only stat() when requiredPádraig Brady2011-12-311-1/+8
| | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): Avoid calling l?stat() when both CAN_MISSING, and CAN_NOLINKS are set, as then we neither need to resolve symlinks or test component existence.
* canonicalize: fix references to stat() and lstat()Pádraig Brady2011-12-301-1/+1
| | | | | | | | | * lib/canonicalize.c (canonicalize_filename_mode): Ensure references always resolve to a replacement function if required (even via a macro). The issue was spotted by Eric Blake and is adequately documented in the docs for stat and lstat.
* canonicalize: add support for not resolving symlinksPádraig Brady2011-12-301-3/+16
| | | | | | | | | | | | | | | | | This will initially be used by a new coreutils realpath command. * lib/canonicalize.h: Add the CAN_NOLINKS flag to indicate we don't want to follow symlinks. Also provide CAN_MODE_MASK to aid setting these existing mutually exclusive values. * lib/canonicalize.c (canonicalize_filename_mode): Extract the flags from can_mode parameter, which are currently just used to select between stat() and lstat(). Also ensure that mutually exclusive values are flagged immediately as invalid. * tests/test-canonicalize.c: Verify symlinks are not followed, and that invalid flag combinations are diagnosed.
* pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.Bruno Haible2011-08-051-0/+6
| | | | | | | | | | | | | | | | | * lib/pathmax.h (PATH_MAX): Leave it undefined on GNU/Hurd. * lib/chdir-long.h: Include pathmax.h. * lib/clean-temp.c (PATH_MAX): Remove code that is done by pathmax.h. * lib/getcwd.c: Include pathmax.h instead of <limits.h>. (PATH_MAX): Remove code that is done by pathmax.h. * lib/canonicalize.c (PATH_MAX): Provide a fallback value. * lib/tmpfile.c: Add a comment. * m4/pathmax.m4 (gl_PATHMAX): Don't test for pathconf. * modules/chdir-long (Depends-on): Add pathmax. * modules/getcwd (Depends-on): Add pathmax. * tests/test-getcwd.c (test_abort_bug): Avoid syntax error when PATH_MAX is not defined. * doc/posix-headers/limits.texi: Mention the pathmax module. * NEWS: Mention the change.
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-1/+1
| | | | Run the new "make update-copyright" rule.
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* canonicalize: reduce memory usageEric Blake2009-12-191-0/+2
| | | | | | | | | | | | | | canonicalize was returning a 4k buffer for everything, even though the majority of canonical path names are much shorter. This resulted in a lot of unused memory, which in turn made tar run out of memory when tracking a lot of files: http://lists.gnu.org/archive/html/bug-tar/2009-12/msg00011.html * lib/canonicalize.c (canonicalize_filename_mode): Trim the allocation to size. Reported by Solar Designer <solar@openwall.com>. Signed-off-by: Eric Blake <ebb9@byu.net>
* Use spaces for indentation, not tabs.Bruno Haible2009-12-101-141/+141
|
* canonicalize: in CAN_ALL_BUT_LAST, allow trailing slashEric Blake2009-09-171-2/+6
| | | | | | | | | | | Coreutils' `readlink -f foo/' should not fail if lstat("foo") gives ENOENT. * lib/canonicalize.c (canonicalize_filename_mode): Skip trailing slashes when checking if last component is missing. * tests/test-canonicalize.c (main): Test this. Signed-off-by: Eric Blake <ebb9@byu.net>
* canonicalize, canonicalize-lgpl: honor // if distinct from /Eric Blake2009-09-171-4/+25
| | | | | | | | | | | | | | | | | | * modules/canonicalize (Files): Add double-slash-root.m4. * modules/canonicalize-lgpl (Files): Likewise. * m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE) (gl_CANONICALIZE_LGPL_SEPARATE): Add dependency. * lib/canonicalize.c (DOUBLE_SLASH_IS_DISTINCT_ROOT): Provide fallback definition. (canonicalize_filename_mode): Use it to protect //. * lib/canonicalize-lgpl.c (DOUBLE_SLASH_IS_DISTINCT_ROOT) (__realpath): Likewise. * tests/test-canonicalize.c (main): Test this. * tests/test-canonicalize-lgpl.c (main): Likewise. * modules/canonicalize-tests (Depends-on): Add same-inode. * modules/canonicalize-lgpl-tests (Depends-on): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* canonicalize-lgpl: fix glibc bug with trailing slashEric Blake2009-09-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Consolidate the m4 macros into a single file, since both modules now have to worry about replacing canonicalize_file_name on buggy glibc. * m4/canonicalize-lgpl.m4: Move contents... * m4/canonicalize.m4: ...here. (gl_CANONICALIZE_LGPL): Factor realpath check... (gl_FUNC_REALPATH_WORKS): ...into new macro. Enhance to catch glibc 2.3.5 bug, fixed 2005-04-27. (gl_FUNC_CANONICALIZE_FILENAME_MODE): Use it. (gl_PREREQ_CANONICALIZE_LGPL): Inline... (gl_CANONICALIZE_LGPL_SEPARATE): ...into this macro. * modules/canonicalize-lgpl (Files): Manage file rename. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Provide default. * modules/stdlib (Makefile.am): Substitute witness. * lib/stdlib.in.h (canonicalize_file_name): Declare if replacement is needed. * lib/canonicalize-lgpl.c: Also compile if canonicalize_file_name replacement is required. * lib/canonicalize.c (canonicalize_file_name): Likewise. * doc/glibc-functions/canonicalize_file_name.texi (canonicalize_file_name): Document this. * doc/posix-functions/realpath.texi (realpath): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>