]> granicus.if.org Git - sudo/commitdiff
Use PATH_MAX, not MAXPATHLEN since the former is standardized.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Jun 2004 01:22:27 +0000 (01:22 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Jun 2004 01:22:27 +0000 (01:22 +0000)
CHANGES
alloc.c
check.c
compat.h
find_path.c
getcwd.c
parse.c
sudo.c
sudo.h
visudo.c

diff --git a/CHANGES b/CHANGES
index fe2a4ef530821754e4a263b9acc5f109cc077e16..0639f45e76954a08ae8a281095a96a6881dc77c9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1695,3 +1695,5 @@ Sudo 1.6.7p5 released.
 
 533) Fixed several issues when closing all open descriptors.  Sudo now uses
      closefrom() if it exists.
+
+534) Use PATH_MAX, not MAXPATHLEN since the former is standardized.
diff --git a/alloc.c b/alloc.c
index 7721947127d7cf600668df8604cc9ee0469f64cf..3db6e6de71908783ee3283d9ef81709dc20351bc 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -46,7 +46,6 @@
 #else
 # include "emul/err.h"
 #endif /* HAVE_ERR_H */
-#include <limits.h>
 
 #include "sudo.h"
 
diff --git a/check.c b/check.c
index e450e47667975a3af73a642c9cae53f4c087e57d..efa957189cea755210edba5f53179e2b18c029d2 100644 (file)
--- a/check.c
+++ b/check.c
@@ -316,7 +316,7 @@ build_timestamp(timestampdir, timestampfile)
 
     dirparent = def_timestampdir;
     len = easprintf(timestampdir, "%s/%s", dirparent, user_name);
-    if (len >= MAXPATHLEN)
+    if (len >= PATH_MAX)
        log_error(0, "timestamp path too long: %s", timestampdir);
 
     /*
@@ -335,12 +335,12 @@ build_timestamp(timestampdir, timestampfile)
                p, *user_runas);
        else
            len = easprintf(timestampfile, "%s/%s/%s", dirparent, user_name, p);
-       if (len >= MAXPATHLEN)
+       if (len >= PATH_MAX)
            log_error(0, "timestamp path too long: %s", timestampfile);
     } else if (def_targetpw) {
        len = easprintf(timestampfile, "%s/%s/%s", dirparent, user_name,
            *user_runas);
-       if (len >= MAXPATHLEN)
+       if (len >= PATH_MAX)
            log_error(0, "timestamp path too long: %s", timestampfile);
     } else
        *timestampfile = NULL;
index ce5c48c6daace287275cf2669c976435f119c85b..381eafda689b2b40ab5e02bff5d48b11b98271f4 100644 (file)
--- a/compat.h
+++ b/compat.h
 #endif /* __P */
 
 /*
- * Some systems (ie ISC V/386) do not define MAXPATHLEN even in param.h
+ * Some systems do not define PATH_MAX.
  */
-#ifndef MAXPATHLEN
-# define MAXPATHLEN            1024
+#ifndef PATH_MAX
+# ifdef MAXPATHLEN
+#  define PATH_MAX             MAXPATHLEN
+# else
+#  ifdef _POSIX_PATH_MAX
+#   define PATH_MAX            _POSIX_PATH_MAX
+#  else
+#   define PATH_MAX            1024
+#  endif
+# endif
 #endif
 
 /*
index cbfb880e9164d07811773c9472e7df6ece161435..2ade456a143d33c490d651a2767634ca60b006f6 100644 (file)
@@ -67,14 +67,14 @@ find_path(infile, outfile, path)
     char **outfile;            /* result parameter */
     char *path;                        /* path to search */
 {
-    static char command[MAXPATHLEN]; /* qualified filename */
+    static char command[PATH_MAX]; /* qualified filename */
     char *n;                   /* for traversing path */
     char *origpath;            /* so we can free path later */
     char *result = NULL;       /* result of path/file lookup */
     int checkdot = 0;          /* check current dir? */
     int len;                   /* length parameter */
 
-    if (strlen(infile) >= MAXPATHLEN)
+    if (strlen(infile) >= PATH_MAX)
        errx(1, "%s: File name too long", infile);
 
     /*
index 2d9fe51214eb48d3efcfdba83e91e3bb99af875f..e5c33b02b99f64d7b40733d461a7dd4bee3869c7 100644 (file)
--- a/getcwd.c
+++ b/getcwd.c
@@ -131,7 +131,7 @@ getcwd(pt, size)
         */
        if ((up = malloc(upsize = 1024 - 4)) == NULL)
                goto err;
-       eup = up + MAXPATHLEN;
+       eup = up + PATH_MAX;
        bup = up;
        up[0] = '.';
        up[1] = '\0';
diff --git a/parse.c b/parse.c
index 7a1d2321e5e2835c51709e3d90311f923dca0ddd..12f6835cadde7abfe144c3d439abd17c9258c340 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -238,7 +238,7 @@ command_matches(cmnd, cmnd_args, path, sudoers_args)
     struct stat pst;
     DIR *dirp;
     struct dirent *dent;
-    char buf[MAXPATHLEN];
+    char buf[PATH_MAX];
     static char *cmnd_base;
 
     /* Check for pseudo-commands */
@@ -350,7 +350,7 @@ command_matches(cmnd, cmnd_args, path, sudoers_args)
            return(FALSE);
 
        while ((dent = readdir(dirp)) != NULL) {
-           /* ignore paths > MAXPATHLEN (XXX - log) */
+           /* ignore paths > PATH_MAX (XXX - log) */
            if (strlcpy(buf, path, sizeof(buf)) >= sizeof(buf) ||
                strlcat(buf, dent->d_name, sizeof(buf)) >= sizeof(buf))
                continue;
diff --git a/sudo.c b/sudo.c
index a0169fbbbf4263508895f5cbf3ab94b196dcec71..abe3a2701e7bf0437711332fd28bd4a7f2d7ee8b 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -497,7 +497,7 @@ init_vars(sudo_mode)
     int nohostname, rval;
 
     /* Sanity check command from user. */
-    if (user_cmnd == NULL && strlen(NewArgv[0]) >= MAXPATHLEN)
+    if (user_cmnd == NULL && strlen(NewArgv[0]) >= PATH_MAX)
        errx(1, "%s: File name too long", NewArgv[0]);
 
 #ifdef HAVE_TZSET
diff --git a/sudo.h b/sudo.h
index 7908f34ccbe6dc0cb26cd9bfa22c97320d77ef86..d458b4181404970b79d0a887b1890a90c98d340b 100644 (file)
--- a/sudo.h
+++ b/sudo.h
@@ -24,6 +24,7 @@
 #define _SUDO_SUDO_H
 
 #include <pathnames.h>
+#include <limits.h>
 #include "compat.h"
 #include "defaults.h"
 #include "logging.h"
@@ -37,7 +38,7 @@ struct sudo_user {
     char *path;
     char *shell;
     char *tty;
-    char  cwd[MAXPATHLEN];
+    char  cwd[PATH_MAX];
     char *host;
     char *shost;
     char **runas;
index 66cae343ae51c0e61fca8285307b7c3f0d23b7e7..e0910dec76aabc04e46c1c9366834c098c8881fb 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -119,7 +119,7 @@ main(argc, argv)
     int argc;
     char **argv;
 {
-    char buf[MAXPATHLEN*2];            /* buffer used for copying files */
+    char buf[PATH_MAX*2];              /* buffer used for copying files */
     char *Editor;                      /* editor to use */
     char *UserEditor;                  /* editor user wants to use */
     char *EditorPath;                  /* colon-separated list of editors */