diff options
author | Paul Smith <psmith@gnu.org> | 2022-10-22 19:42:07 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-10-22 22:40:26 -0400 |
commit | f364e0d8d6e03f1e8bc995641530e4df6598704c (patch) | |
tree | f7700f2873b0c5b1dd5dffbb741c6f5f3ce43f01 /src | |
parent | bb0c05a7f0329dd2ea38021e9c0b9e74e0cdb7de (diff) | |
download | make-git-f364e0d8d6e03f1e8bc995641530e4df6598704c.tar.gz |
Set PATH_MAX on systems without a default value
Some systems (HURD) use fully-dynamic pathnames, with no limit.
We can't support this without significant effort so for now set
PATH_MAX to a large value.
* src/makeint.h: Set PATH_MAX to 4096 if not set and MAXPATHLEN
is also not set. Remove MAXPATHLEN setting: we won't use it.
* src/misc.c (get_path_max): If we can't get the path max via
pathconf() use the default PATH_MAX.
* src/dir.c (find_directory) [W32]: Use MAX_PATH not MAXPATHLEN.
(local_stat) [W32]: Ditto.
* src/job.c (create_batch_file) [W32]: Ditto.
* src/remake.c (name_mtime) [W32]: Ditto.
* src/w32/w32os.c (os_anontmp) [W32]: Ditto.
Diffstat (limited to 'src')
-rw-r--r-- | src/dir.c | 8 | ||||
-rw-r--r-- | src/job.c | 2 | ||||
-rw-r--r-- | src/makeint.h | 9 | ||||
-rw-r--r-- | src/misc.c | 6 | ||||
-rw-r--r-- | src/remake.c | 3 | ||||
-rw-r--r-- | src/w32/w32os.c | 2 |
6 files changed, 16 insertions, 14 deletions
@@ -521,7 +521,7 @@ find_directory (const char *name) /* See if the directory exists. */ #if defined(WINDOWS32) { - char tem[MAXPATHLEN], *tstart, *tend; + char tem[MAX_PATH+1], *tstart, *tend; size_t len = strlen (name); /* Remove any trailing slashes. Windows32 stat fails even on @@ -1314,10 +1314,10 @@ local_stat (const char *path, struct stat *buf) foo/. => foo without checking first that foo is a directory. */ if (plen > 2 && path[plen - 1] == '.' && ISDIRSEP (path[plen - 2])) { - char parent[MAXPATHLEN+1]; + char parent[MAX_PATH+1]; - strncpy (parent, path, MAXPATHLEN); - parent[MIN(plen - 2, MAXPATHLEN)] = '\0'; + strncpy (parent, path, MAX_PATH); + parent[MIN(plen - 2, MAX_PATH)] = '\0'; if (stat (parent, buf) < 0 || !_S_ISDIR (buf->st_mode)) return -1; } @@ -283,7 +283,7 @@ create_batch_file (char const *base, int unixy, int *fd) { const char *const ext = unixy ? "sh" : "bat"; const char *error_string = NULL; - char temp_path[MAXPATHLEN]; /* need to know its length */ + char temp_path[MAX_PATH+1]; /* need to know its length */ unsigned path_size = GetTempPath (sizeof temp_path, temp_path); int path_is_dot = 0; /* The following variable is static so we won't try to reuse a name diff --git a/src/makeint.h b/src/makeint.h index c924b31e..f9de63d0 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -152,13 +152,14 @@ extern int errno; #endif #ifndef PATH_MAX -# ifndef POSIX +# ifdef MAXPATHLEN # define PATH_MAX MAXPATHLEN +# else +/* Some systems (HURD) have fully dynamic pathnames with no maximum. + Ideally we'd support this but it will take some work. */ +# define PATH_MAX 4096 # endif #endif -#ifndef MAXPATHLEN -# define MAXPATHLEN 1024 -#endif #ifdef PATH_MAX # define GET_PATH_MAX PATH_MAX @@ -769,11 +769,11 @@ get_path_max (void) if (value == 0) { - long int x = pathconf ("/", _PC_PATH_MAX); + long x = pathconf ("/", _PC_PATH_MAX); if (x > 0) - value = x; + value = (unsigned int) x; else - return MAXPATHLEN; + value = PATH_MAX; } return value; diff --git a/src/remake.c b/src/remake.c index 4c87f783..4ce3d2a3 100644 --- a/src/remake.c +++ b/src/remake.c @@ -34,6 +34,7 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include <starlet.h> #endif #ifdef WINDOWS32 +#include <windows.h> #include <io.h> #include <sys/stat.h> #if defined(_MSC_VER) && _MSC_VER > 1200 @@ -1551,7 +1552,7 @@ name_mtime (const char *name) #if defined(WINDOWS32) { - char tem[MAXPATHLEN], *tstart, *tend; + char tem[MAX_PATH+1], *tstart, *tend; const char *p = name + strlen (name); /* Remove any trailing slashes and "."/"..". MS-Windows stat diff --git a/src/w32/w32os.c b/src/w32/w32os.c index 28b6430f..9c5dec24 100644 --- a/src/w32/w32os.c +++ b/src/w32/w32os.c @@ -115,7 +115,7 @@ check_io_state () int os_anontmp () { - char temp_path[MAXPATHLEN]; + char temp_path[MAX_PATH+1]; unsigned path_size = GetTempPath (sizeof (temp_path), temp_path); int using_cwd = 0; |