Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
955f2f03
Commit
955f2f03
authored
Feb 20, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
race-condition safe implementation of test_if_data_home_dir()
don't realpath() twice
parent
93cb0246
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
15 deletions
+34
-15
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+31
-13
sql/sql_parse.h
sql/sql_parse.h
+2
-1
No files found.
sql/mysqld.cc
View file @
955f2f03
...
@@ -7267,7 +7267,7 @@ static int mysql_init_variables(void)
...
@@ -7267,7 +7267,7 @@ static int mysql_init_variables(void)
mysql_home
[
0
]
=
pidfile_name
[
0
]
=
log_error_file
[
0
]
=
0
;
mysql_home
[
0
]
=
pidfile_name
[
0
]
=
log_error_file
[
0
]
=
0
;
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
/* We can only test for sub paths if my_symlink.c is using realpath */
/* We can only test for sub paths if my_symlink.c is using realpath */
mysys_test_invalid_symlink
=
test_if
_data_home_dir
;
mysys_test_invalid_symlink
=
path_starts_from
_data_home_dir
;
#endif
#endif
opt_log
=
opt_slow_log
=
0
;
opt_log
=
opt_slow_log
=
0
;
opt_bin_log
=
opt_bin_log_used
=
0
;
opt_bin_log
=
opt_bin_log_used
=
0
;
...
...
sql/sql_parse.cc
View file @
955f2f03
...
@@ -7697,26 +7697,20 @@ bool check_ident_length(LEX_STRING *ident)
...
@@ -7697,26 +7697,20 @@ bool check_ident_length(LEX_STRING *ident)
Check if path does not contain mysql data home directory
Check if path does not contain mysql data home directory
SYNOPSIS
SYNOPSIS
test_if
_data_home_dir()
path_starts_from
_data_home_dir()
dir directory
dir directory
, with all symlinks resolved
RETURN VALUES
RETURN VALUES
0 ok
0 ok
1 error ; Given path contains data directory
1 error ; Given path contains data directory
*/
*/
C_MODE_START
extern
"C"
{
int
test_if_data_home_dir
(
const
char
*
dir
)
int
path_starts_from_data_home_dir
(
const
char
*
path
)
{
{
char
path
[
FN_REFLEN
];
int
dir_len
=
strlen
(
path
);
int
dir_len
;
DBUG_ENTER
(
"path_starts_from_data_home_dir"
);
DBUG_ENTER
(
"test_if_data_home_dir"
);
if
(
!
dir
)
DBUG_RETURN
(
0
);
(
void
)
fn_format
(
path
,
dir
,
""
,
""
,
MY_RETURN_REAL_PATH
);
dir_len
=
strlen
(
path
);
if
(
mysql_unpacked_real_data_home_len
<=
dir_len
)
if
(
mysql_unpacked_real_data_home_len
<=
dir_len
)
{
{
if
(
dir_len
>
mysql_unpacked_real_data_home_len
&&
if
(
dir_len
>
mysql_unpacked_real_data_home_len
&&
...
@@ -7744,7 +7738,31 @@ int test_if_data_home_dir(const char *dir)
...
@@ -7744,7 +7738,31 @@ int test_if_data_home_dir(const char *dir)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
C_MODE_END
}
/*
Check if path does not contain mysql data home directory
SYNOPSIS
test_if_data_home_dir()
dir directory
RETURN VALUES
0 ok
1 error ; Given path contains data directory
*/
int
test_if_data_home_dir
(
const
char
*
dir
)
{
char
path
[
FN_REFLEN
];
DBUG_ENTER
(
"test_if_data_home_dir"
);
if
(
!
dir
)
DBUG_RETURN
(
0
);
(
void
)
fn_format
(
path
,
dir
,
""
,
""
,
MY_RETURN_REAL_PATH
);
DBUG_RETURN
(
path_starts_from_data_home_dir
(
path
));
}
/**
/**
...
...
sql/sql_parse.h
View file @
955f2f03
...
@@ -33,7 +33,8 @@ enum enum_mysql_completiontype {
...
@@ -33,7 +33,8 @@ enum enum_mysql_completiontype {
COMMIT_RELEASE
=-
1
,
COMMIT
=
0
,
COMMIT_AND_CHAIN
=
6
COMMIT_RELEASE
=-
1
,
COMMIT
=
0
,
COMMIT_AND_CHAIN
=
6
};
};
extern
"C"
int
test_if_data_home_dir
(
const
char
*
dir
);
extern
"C"
int
path_starts_from_data_home_dir
(
const
char
*
dir
);
int
test_if_data_home_dir
(
const
char
*
dir
);
bool
multi_update_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_update_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_delete_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_delete_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment