summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_symlink.c2
-rw-r--r--mysys/mysys_priv.h11
2 files changed, 11 insertions, 2 deletions
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index 72648d4c9a8..06f6a29e4a0 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -205,7 +205,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd)
{
- char buf[PATH_MAX+1];
+ char buf[FN_REFLEN + 1];
char *s= buf, *e= buf+1, *end= strnmov(buf, pathname, sizeof(buf));
int fd, dfd= -1;
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index da11b86e768..892e09148ef 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -126,12 +126,21 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd);
res= AT; \
if (dfd >= 0) close(dfd); \
return res;
-#elif defined(HAVE_REALPATH)
+#elif defined(HAVE_REALPATH) && defined(PATH_MAX)
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
char buf[PATH_MAX+1]; \
if (realpath(pathname, buf) == NULL) return -1; \
if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \
return NOAT;
+#elif defined(HAVE_REALPATH)
+#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
+ char *buf= realpath(pathname, NULL); \
+ int res; \
+ if (buf == NULL) return -1; \
+ if (strcmp(pathname, buf)) { errno= ENOTDIR; res= -1; } \
+ else res= NOAT; \
+ free(buf); \
+ return res;
#else
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
return NOAT;