161
Checks if the drive letter supplied is valid or not. Valid drive
162
letters are A to Z, both lower case and upper case.
164
@param drive_letter : The drive letter to validate.
166
@return TRUE if the drive exists, FALSE otherwise.
168
static my_bool does_drive_exists(char drive_letter)
170
DWORD drive_mask= GetLogicalDrives();
171
drive_letter= toupper(drive_letter);
173
return (drive_letter >= 'A' && drive_letter <= 'Z') &&
174
(drive_mask & (0x1 << (drive_letter - 'A')));
179
Verifies if the file name supplied is allowed or not. On Windows
180
file names with a colon (:) are not allowed because such file names
181
store data in Alternate Data Streams which can be used to hide
184
@param name contains the file name with or without path
185
@param length contains the length of file name
187
@return TRUE if the file name is allowed, FALSE otherwise.
189
my_bool is_filename_allowed(const char *name __attribute__((unused)),
190
size_t length __attribute__((unused)))
194
For Windows, check if the file name contains : character.
195
Start from end of path and search if the file name contains :
197
const char* ch = NULL;
198
for(ch= name + length - 1; ch >= name; --ch)
200
if (FN_LIBCHAR == *ch || '/' == *ch)
205
File names like C:foobar.txt are allowed since the syntax means
206
file foobar.txt in current directory of C drive. However file
207
names likes CC:foobar are not allowed since this syntax means ADS
210
return ((ch - name == 1) && does_drive_exists(*name));
215
/* For other platforms, file names can contain colon : */
218
} /* is_filename_allowed */
159
220
#if defined(__WIN__) || defined(__EMX__)
177
238
const char **reserved_name;
178
239
DBUG_ENTER("check_if_legal_filename");
241
if(!is_filename_allowed(path, strlen(path)))
180
244
path+= dirname_length(path); /* To start of filename */
181
245
if (!(end= strchr(path, FN_EXTCHAR)))
182
246
end= strend(path);