| 2207 | */ |
| 2208 | |
| 2209 | bool is_secure_file_path(char *path) |
| 2210 | { |
| 2211 | char buff1[FN_REFLEN], buff2[FN_REFLEN]; |
| 2212 | size_t opt_secure_file_priv_len; |
| 2213 | |
| 2214 | /* |
| 2215 | --secure-file-priv without argument means |
| 2216 | disable SELECT INTO OUTFILE/LOAD DATA INFILE |
| 2217 | */ |
| 2218 | if (opt_secure_file_priv_noarg) |
| 2219 | return FALSE; |
| 2220 | |
| 2221 | /* |
| 2222 | All paths are secure if opt_secure_file_path is 0 |
| 2223 | */ |
| 2224 | if (!opt_secure_file_priv) |
| 2225 | return TRUE; |
| 2226 | |
| 2227 | opt_secure_file_priv_len= strlen(opt_secure_file_priv); |
| 2228 | |
| 2229 | if (strlen(path) >= FN_REFLEN) |
| 2230 | return FALSE; |
| 2231 | |
| 2232 | if (my_realpath(buff1, path, 0)) |
| 2233 | { |
| 2234 | /* |
| 2235 | The supplied file path might have been a file and not a directory. |
| 2236 | */ |
| 2237 | int length= (int)dirname_length(path); |
| 2238 | if (length >= FN_REFLEN) |
| 2239 | return FALSE; |
| 2240 | memcpy(buff2, path, length); |
| 2241 | buff2[length]= '\0'; |
| 2242 | if (length == 0 || my_realpath(buff1, buff2, 0)) |
| 2243 | return FALSE; |
| 2244 | } |
| 2245 | convert_dirname(buff2, buff1, NullS); |
| 2246 | if (!lower_case_file_system) |
| 2247 | { |
| 2248 | if (strncmp(opt_secure_file_priv, buff2, opt_secure_file_priv_len)) |
| 2249 | return FALSE; |
| 2250 | } |
| 2251 | else |
| 2252 | { |
| 2253 | if (files_charset_info->coll->strnncoll(files_charset_info, |
| 2254 | (uchar *) buff2, strlen(buff2), |
| 2255 | (uchar *) opt_secure_file_priv, |
| 2256 | opt_secure_file_priv_len, |
| 2257 | TRUE)) |
| 2258 | return FALSE; |
| 2259 | } |
| 2260 | return TRUE; |
| 2261 | } |
| 2262 | |
| 2263 | |
| 2264 | static int fix_paths(void) |
no test coverage detected