summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2017-08-09 08:56:11 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2017-08-09 08:56:11 +0300
commit56b03e308fb4c0feee166ddf6a707d855affa3c3 (patch)
treefc4e16093800cf4cbf1cc54fceb0b7280c4212ba /mysys
parent4f40f87c48a9ee252f797b5d760a6b6f07cc3815 (diff)
parenta346a5613ee7c0b17b0b4ce377659c996ef6bb75 (diff)
downloadmariadb-git-56b03e308fb4c0feee166ddf6a707d855affa3c3.tar.gz
Merge tag 'mariadb-10.0.32' into 10.0-galera
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_fopen.c2
-rw-r--r--mysys/my_symlink.c2
-rw-r--r--mysys/mysys_priv.h11
-rw-r--r--mysys/stacktrace.c2
4 files changed, 13 insertions, 4 deletions
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 533c223be66..a7a0967f909 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -143,7 +143,7 @@ static int no_close(void *cookie __attribute__((unused)))
/*
A hack around a race condition in the implementation of freopen.
- The race condition steams from the fact that the current fd of
+ The race condition stems from the fact that the current fd of
the stream is closed before its number is used to duplicate the
new file descriptor. This defeats the desired atomicity of the
close and duplicate of dup2().
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 51650567609..b33e155a718 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -110,12 +110,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;
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 746b99d6112..2b83c5d5479 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -766,7 +766,7 @@ int my_safe_print_str(const char *val, int len)
size_t my_write_stderr(const void *buf, size_t count)
{
- return (size_t) write(STDERR_FILENO, buf, count);
+ return (size_t) write(fileno(stderr), buf, count);
}