diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2016-09-23 18:55:44 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2016-09-27 10:54:01 +0000 |
commit | f1aefd9d758a3d464d77ede64f960ff33326eb72 (patch) | |
tree | 8644ab86dab31f9350d66f0b1458f1f4d83d59f9 /mysys/my_access.c | |
parent | 661d08c36ca9181e9f2469c66160e877e284c23f (diff) | |
download | mariadb-git-f1aefd9d758a3d464d77ede64f960ff33326eb72.tar.gz |
MDEV-10823 Certain unicode characters in hostname prevent mysqld from starting
Server uses gethostname() for the default base name for pid/log files.
If a character is not representable in current ANSI encoding, gethostname
replaces it with question mark. Thus, generated log file name would also
contain a question mark. However, Windows forbids certain characters in
filenames, among them '?'.
This is described in MSDN article https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
At attempts to create the file via freopen() fails, thus server would not
be able to start.
The fix is to verify hostname and fall back to "mysql", if
invalid characters are found.
Diffstat (limited to 'mysys/my_access.c')
-rw-r--r-- | mysys/my_access.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mysys/my_access.c b/mysys/my_access.c index 68cd01d33e6..0da5e7f0bf0 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -173,6 +173,11 @@ static my_bool does_drive_exists(char drive_letter) file names with a colon (:) are not allowed because such file names store data in Alternate Data Streams which can be used to hide the data. + Apart from colon, other characters that are not allowed in filenames + on Windows are greater/less sign, double quotes, forward slash, backslash, + pipe and star characters. + + See MSDN documentation on filename restrictions. @param name contains the file name with or without path @param length contains the length of file name @@ -181,6 +186,8 @@ static my_bool does_drive_exists(char drive_letter) @return TRUE if the file name is allowed, FALSE otherwise. */ +#define ILLEGAL_FILENAME_CHARS "<>:\"/\|?*" + my_bool is_filename_allowed(const char *name __attribute__((unused)), size_t length __attribute__((unused)), my_bool allow_current_dir __attribute__((unused))) @@ -205,6 +212,8 @@ my_bool is_filename_allowed(const char *name __attribute__((unused)), return (allow_current_dir && (ch - name == 1) && does_drive_exists(*name)); } + else if (strchr(ILLEGAL_FILENAME_CHARS, *ch)) + return FALSE; } return TRUE; } /* is_filename_allowed */ |