From 4717ea4a97af59fca6a88a84e10add5d9539a473 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 9 Feb 2007 17:35:15 +0100 Subject: [PATCH] clean up realpath.[ch] includes and macros Signed-off-by: Karel Zak --- mount/realpath.c | 11 ++++------- mount/realpath.h | 10 ++++++++++ mount/swapon.c | 5 ----- 3 files changed, 14 insertions(+), 12 deletions(-) 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" -- 2.39.5