Fix cache_dir path handling in MySQLAuth
The path that was given as the option for the cache directory wasn't properly checked for terminating forward slashes. Due to this, the cache file was created with the wrong name.
This commit is contained in:
parent
4e07c3313c
commit
8f55cfbc16
@ -72,7 +72,7 @@ char* replace_literal(char* haystack,
|
||||
const char* replacement);
|
||||
char* replace_quoted(const char** src, const size_t* srcsize, char** dest, size_t* destsize);
|
||||
|
||||
void clean_up_pathname(char *path);
|
||||
bool clean_up_pathname(char *path);
|
||||
|
||||
bool mxs_mkdir_all(const char *path, int mask);
|
||||
|
||||
|
@ -315,14 +315,15 @@ char *create_hex_sha1_sha1_passwd(char *passwd)
|
||||
* Remove duplicate and trailing forward slashes from a path.
|
||||
* @param path Path to clean up
|
||||
*/
|
||||
void clean_up_pathname(char *path)
|
||||
bool clean_up_pathname(char *path)
|
||||
{
|
||||
char *data = path;
|
||||
size_t len = strlen(path);
|
||||
|
||||
if (len > PATH_MAX)
|
||||
{
|
||||
MXS_WARNING("Pathname too long: %s", path);
|
||||
MXS_ERROR("Pathname too long: %s", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (*data != '\0')
|
||||
@ -350,6 +351,8 @@ void clean_up_pathname(char *path)
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,7 +155,8 @@ static void* mysql_auth_init(char **options)
|
||||
|
||||
if (strcmp(options[i], "cache_dir") == 0)
|
||||
{
|
||||
if ((instance->cache_dir = MXS_STRDUP(value)) == NULL)
|
||||
if ((instance->cache_dir = MXS_STRDUP(value)) == NULL ||
|
||||
!clean_up_pathname(instance->cache_dir))
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
@ -903,7 +904,7 @@ static int mysql_auth_load_users(SERV_LISTENER *port)
|
||||
|
||||
if (instance->cache_dir)
|
||||
{
|
||||
strcpy(path, instance->cache_dir);
|
||||
snprintf(path, sizeof(path) - sizeof(DBUSERS_FILE) - 1, "%s/", instance->cache_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user