mbox series

[00/17] posix: glob fixes and refactor

Message ID 1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org
Headers show
Series posix: glob fixes and refactor | expand

Message

Adhemerval Zanella Netto June 8, 2017, 9:13 p.m. UTC
The set fixes some long standing glob issues (gnulib sync and dandling
symlinks) the refactor current, adjust its tests for libsupport and
refactor current implementation to use a dynarray implementation for
C strings.

To correct provide a C string analogous using dynarray I had to access
its private member directly, so I created a specialized implementation
(malloc/char_array.c) for it.  It currently works similar to dynarray,
by including its header which defines static functions.  If it is the
case, one could its function as an internal API.  I added some
function only to manipulate mainly for the work to refactor glob.

The idea to refactor is mainly to remove the alloca and internal buffer
handling boilerplate usage.  So it does not trace its possible stack
usage using 'alloca_used' variable, which is somewhat fragile (since
it just track glob usage itself).  I used 256 bytes for default
string size (for initial stack allocation), but we can also tune it
if required.

I did not and will not take care of the non-unix code on glob.c (it
is probably broken after the glob refactor).  In fact I would like
to cleanup this implementation even further to remove all code not
really used for GLIBC if gnulib developers want to not keep the
implementation at sync.

Adhemerval Zanella (16):
  posix: Sync glob with gnulib [BZ #1062]
  posix: Allow glob to match dangling symlinks [BZ #866]
  support: Add optstring support
  posix: Adjust glob tests to libsupport
  posix: Consolidate glob implementation
  malloc: Add specialized dynarray for C strings
  posix: Use char_array for internal glob dirname
  posix: Remove glob GET_LOGIN_NAME_MAX usage
  posix: User LOGIN_NAME_MAX for all user name in glob
  posix: Remove alloca usage for GLOB_BRACE on glob
  posix: Remove alloca usage on glob dirname
  posix: Use dynarray for globname in glob
  posix: Remove all alloca usage in glob
  posix: Use char_array for home_dir in glob
  posix: Add common function to get home directory
  posix: More check for overflow allocation in glob

Florian Weimer (1):
  posix: Rewrite to use struct scratch_buffer instead of extend_alloca

 malloc/Makefile                                    |    1 +
 malloc/char_array.c                                |  256 +++++
 malloc/malloc-internal.h                           |   14 +
 malloc/tst-char_array.c                            |  107 ++
 posix/Makefile                                     |   17 +-
 posix/bug-glob1.c                                  |   88 --
 posix/bug-glob3.c                                  |   45 -
 posix/glob.c                                       | 1166 ++++++++------------
 posix/glob_internal.h                              |   57 +
 posix/glob_pattern_p.c                             |   29 +
 posix/globfree.c                                   |   37 +
 posix/globfree64.c                                 |   27 +
 posix/globtest.c                                   |  166 +--
 posix/tst-glob_basic.c                             |   41 +
 posix/tst-glob_common.c                            |  103 ++
 posix/{bug-glob2.c => tst-glob_memory.c}           |  100 +-
 posix/tst-glob_symlinks.c                          |  133 +++
 posix/tst-gnuglob.c                                |  109 +-
 support/support_test_main.c                        |    3 +-
 support/test-driver.c                              |    9 +
 support/test-driver.h                              |    1 +
 sysdeps/gnu/glob64.c                               |   25 -
 sysdeps/unix/sysv/linux/Makefile                   |    2 +-
 sysdeps/unix/sysv/linux/alpha/Makefile             |    4 -
 sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} |   11 -
 sysdeps/unix/sysv/linux/alpha/globfree.c           |   36 +
 sysdeps/unix/sysv/linux/arm/glob64.c               |    1 -
 sysdeps/unix/sysv/linux/glob.c                     |   23 +
 sysdeps/unix/sysv/linux/glob64.c                   |   55 +
 sysdeps/unix/sysv/linux/globfree.c                 |   23 +
 sysdeps/unix/sysv/linux/globfree64.c               |    0
 sysdeps/unix/sysv/linux/i386/alphasort64.c         |    2 +-
 sysdeps/unix/sysv/linux/i386/getdents64.c          |    2 +-
 sysdeps/unix/sysv/linux/i386/readdir64.c           |    2 +-
 sysdeps/unix/sysv/linux/i386/readdir64_r.c         |    2 +-
 sysdeps/unix/sysv/linux/i386/versionsort64.c       |    2 +-
 sysdeps/unix/sysv/linux/m68k/glob64.c              |    1 -
 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c   |    1 -
 sysdeps/unix/sysv/linux/{i386 => }/olddirent.h     |    0
 .../unix/sysv/linux/{i386/glob64.c => oldglob.c}   |   51 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c |    1 -
 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c      |   20 +
 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c     |    2 +
 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c     |    1 -
 sysdeps/unix/sysv/linux/wordsize-64/glob64.c       |    2 -
 sysdeps/unix/sysv/linux/x86_64/x32/glob.c          |    1 -
 sysdeps/wordsize-64/glob.c                         |    8 -
 sysdeps/wordsize-64/glob64.c                       |    1 -
 48 files changed, 1558 insertions(+), 1230 deletions(-)
 create mode 100644 malloc/char_array.c
 create mode 100644 malloc/tst-char_array.c
 delete mode 100644 posix/bug-glob1.c
 delete mode 100644 posix/bug-glob3.c
 create mode 100644 posix/glob_internal.h
 create mode 100644 posix/glob_pattern_p.c
 create mode 100644 posix/globfree.c
 create mode 100644 posix/globfree64.c
 create mode 100644 posix/tst-glob_basic.c
 create mode 100644 posix/tst-glob_common.c
 rename posix/{bug-glob2.c => tst-glob_memory.c} (76%)
 create mode 100644 posix/tst-glob_symlinks.c
 delete mode 100644 sysdeps/gnu/glob64.c
 rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/glob.c
 create mode 100644 sysdeps/unix/sysv/linux/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree64.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c
 rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%)
 rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (62%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c
 delete mode 100644 sysdeps/wordsize-64/glob.c
 delete mode 100644 sysdeps/wordsize-64/glob64.c

-- 
2.7.4