From 6dd7e40073d6f18bcb287b59256607caea17404a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Jun 2011 01:10:57 -0700 Subject: * lib/getopt.c, lib/stat.c, m4/gl-comp.m4: Merge from gnulib. --- ChangeLog | 4 ++++ lib/getopt.c | 2 +- lib/stat.c | 8 ++++++++ m4/gl-comp.m4 | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9b8e5f762f..8a908f6b95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-23 Paul Eggert + + * lib/getopt.c, lib/stat.c, m4/gl-comp.m4: Merge from gnulib. + 2011-06-22 Paul Eggert Use gnulib's alloca-opt module. diff --git a/lib/getopt.c b/lib/getopt.c index 23510d8afe..2af8352ee9 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') + if (temp[0] == 'W' && temp[1] == ';' && longopts) { char *nameend; const struct option *p; diff --git a/lib/stat.c b/lib/stat.c index cbc9100fd4..f07370dd06 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -38,6 +38,7 @@ orig_stat (const char *filename, struct stat *buf) #include #include #include "dosname.h" +#include "verify.h" /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always @@ -63,6 +64,12 @@ rpl_stat (char const *name, struct stat *st) } #endif /* REPLACE_FUNC_STAT_FILE */ #if REPLACE_FUNC_STAT_DIR + /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also + have a constant PATH_MAX. */ +# ifndef PATH_MAX +# error "Please port this replacement to your platform" +# endif + if (result == -1 && errno == ENOENT) { /* Due to mingw's oddities, there are some directories (like @@ -77,6 +84,7 @@ rpl_stat (char const *name, struct stat *st) char fixed_name[PATH_MAX + 1] = {0}; size_t len = strlen (name); bool check_dir = false; + verify (PATH_MAX <= 4096); if (PATH_MAX <= len) errno = ENAMETOOLONG; else if (len) diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4 index 24141a2639..84b3a0962e 100644 --- a/m4/gl-comp.m4 +++ b/m4/gl-comp.m4 @@ -206,6 +206,9 @@ gl_SYS_STAT_MODULE_INDICATOR([stat]) if $condition; then func_gl_gnulib_m4code_dosname fi + if $condition; then + func_gl_gnulib_m4code_verify + fi fi } func_gl_gnulib_m4code_strtoull () -- cgit v1.2.3