bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/3] provide lighter-weight getcwd


From: Eric Blake
Subject: [PATCH 0/3] provide lighter-weight getcwd
Date: Mon, 25 Apr 2011 16:28:24 -0600

There are three reasons to use the getcwd module:

1. POSIX says getcwd(NULL,0) is unspecified, but most modern systems
behave like glibc (anyone know which systems don't malloc()? Even
Solaris 8 man page says that it mallocs, and mingw mallocs).

2. Linux still has issues with super-deep directories, where we can
work around some (but not all) of those issues by iterating over
readdir() calls to progressively longer ../../ sequences (or more
efficiently, rely on openat() to speed that up).

3. Old systems didn't have getcwd().  But none in the latest matrix.

The first fix is the most important - I've audited and found several
bugs where libvirt wasn't correctly using a POSIX-compliant
ERANGE/realloc() loop in all getcwd() clients, and it is certainly
much more convenient to just rely on the native version to malloc
(or make a replacement that does it for the few broken systems).

The second fix drags in lots of code, including GPL-only stuff.  Letting
software fail rather than trying to handle long paths may be better off,
for software that isn't trying to recover from such a directory (or put
another way, GPL coreutils must continue to be as robust as possible,
but LPGL libvirt could reliably get by with reliably passing errors back
to the caller if used from such a deep directory).

The third is a candidate for our recent obsoletion cleanups.  But
since we already handle it as part of 2, I didn't try very hard.

Here's my take at a series to separate the issue 1 into a lighter-weight
module.  Any thoughts before it is worth committing?

Eric Blake (3):
  getcwd: consolidate m4 files
  getcwd-lgpl: new module
  getcwd: enhance tests

 ChangeLog                       |   24 +++
 MODULES.html.sh                 |    1 +
 doc/posix-functions/getcwd.texi |   13 +-
 lib/getcwd.c                    |  208 +++++++++++++++++----------
 m4/getcwd-abort-bug.m4          |  106 -------------
 m4/getcwd-path-max.m4           |  188 -----------------------
 m4/getcwd.m4                    |  313 ++++++++++++++++++++++++++++++++++++++-
 modules/getcwd                  |    2 -
 modules/getcwd-lgpl             |   25 +++
 modules/getcwd-lgpl-tests       |   12 ++
 modules/getcwd-tests            |    6 +-
 tests/test-getcwd-lgpl.c        |   76 ++++++++++
 tests/test-getcwd.c             |  220 ++++++++++++++++++++++-----
 13 files changed, 776 insertions(+), 418 deletions(-)
 delete mode 100644 m4/getcwd-abort-bug.m4
 delete mode 100644 m4/getcwd-path-max.m4
 create mode 100644 modules/getcwd-lgpl
 create mode 100644 modules/getcwd-lgpl-tests
 create mode 100644 tests/test-getcwd-lgpl.c

-- 
1.7.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]