From: Karel Zak Date: Fri, 9 Feb 2007 16:35:15 +0000 (+0100) Subject: clean up realpath.[ch] includes and macros X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4717ea4a97af59fca6a88a84e10add5d9539a473;p=util-linux clean up realpath.[ch] includes and macros Signed-off-by: Karel Zak --- diff --git a/mount/realpath.c b/mount/realpath.c index 373dbe82..9dc517e4 100644 --- a/mount/realpath.c +++ b/mount/realpath.c @@ -19,18 +19,15 @@ * This routine is part of libc. We include it nevertheless, * since the libc version has some security flaws. */ - -#include /* for PATH_MAX */ -#ifndef PATH_MAX -#define PATH_MAX 8192 -#endif #include #include #include #include "realpath.h" #include "sundries.h" /* for xstrdup */ -#define MAX_READLINKS 32 +#ifndef MAXSYMLINKS +# define MAXSYMLINKS 256 +#endif char * myrealpath(const char *path, char *resolved_path, int maxreslth) { @@ -85,7 +82,7 @@ myrealpath(const char *path, char *resolved_path, int maxreslth) { } /* Protect against infinite loops. */ - if (readlinks++ > MAX_READLINKS) { + if (readlinks++ > MAXSYMLINKS) { errno = ELOOP; goto err; } diff --git a/mount/realpath.h b/mount/realpath.h index 206e53c1..016fc484 100644 --- a/mount/realpath.h +++ b/mount/realpath.h @@ -1 +1,11 @@ +#ifndef REALPATH_H +#define REALPATH_H + +#include +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif + extern char *myrealpath(const char *path, char *resolved_path, int m); + +#endif /* REALPATH_H */ diff --git a/mount/swapon.c b/mount/swapon.c index ef8dcee9..b6bcd750 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -19,11 +19,6 @@ #include "mount_by_label.h" #include "realpath.h" -#include /* for PATH_MAX */ -#ifndef PATH_MAX -#define PATH_MAX 8192 -#endif - #define streq(s, t) (strcmp ((s), (t)) == 0) #define _PATH_FSTAB "/etc/fstab"