mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-39118: test_if_hard_path crashes on recursively resolving $HOME
Problem: When `$HOME` is set to `~/` (or any string starting with `~/`), the `home_dir` is initialized to that value. When `test_if_hard_path` is called on a path starting with `~/`, it replaces the `~/` prefix by recursively calling `test_if_hard_path(home_dir)` leading to infinite recursion and a crash. Fix: Add a check in `test_if_hard_path` to see if `home_dir` itself begins with `~/`. If it does, skip the recursive call to prevent the infinite loop.
This commit is contained in:
committed by
Raghunandan Bhat
parent
7f8dc5004d
commit
86a15de7c0
4
mysql-test/main/mdev_39118-win.cnf
Normal file
4
mysql-test/main/mdev_39118-win.cnf
Normal file
@@ -0,0 +1,4 @@
|
||||
!include include/default_my.cnf
|
||||
|
||||
[ENV]
|
||||
HOME=~\
|
||||
6
mysql-test/main/mdev_39118-win.result
Normal file
6
mysql-test/main/mdev_39118-win.result
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# MDEV-39118: test_if_hard_path() crashes on recursively resolving $HOME
|
||||
#
|
||||
create table t (c int) engine=MyISAM data directory="~\\foo\\bar";
|
||||
ERROR 42000: Incorrect table name '~\foo\bar'
|
||||
# End of 10.11 tests
|
||||
9
mysql-test/main/mdev_39118-win.test
Normal file
9
mysql-test/main/mdev_39118-win.test
Normal file
@@ -0,0 +1,9 @@
|
||||
--source include/windows.inc
|
||||
--echo #
|
||||
--echo # MDEV-39118: test_if_hard_path() crashes on recursively resolving \$HOME
|
||||
--echo #
|
||||
|
||||
--error ER_WRONG_TABLE_NAME
|
||||
create table t (c int) engine=MyISAM data directory="~\\foo\\bar";
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
4
mysql-test/main/mdev_39118.cnf
Normal file
4
mysql-test/main/mdev_39118.cnf
Normal file
@@ -0,0 +1,4 @@
|
||||
!include include/default_my.cnf
|
||||
|
||||
[ENV]
|
||||
HOME=~/
|
||||
6
mysql-test/main/mdev_39118.result
Normal file
6
mysql-test/main/mdev_39118.result
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# MDEV-39118: test_if_hard_path() crashes on recursively resolving $HOME
|
||||
#
|
||||
create table t (c int) engine=MyISAM data directory="~/foo/bar";
|
||||
ERROR 42000: Incorrect table name '~/foo/bar'
|
||||
# End of 10.11 tests
|
||||
9
mysql-test/main/mdev_39118.test
Normal file
9
mysql-test/main/mdev_39118.test
Normal file
@@ -0,0 +1,9 @@
|
||||
--source include/not_windows.inc
|
||||
--echo #
|
||||
--echo # MDEV-39118: test_if_hard_path() crashes on recursively resolving \$HOME
|
||||
--echo #
|
||||
|
||||
--error ER_WRONG_TABLE_NAME
|
||||
create table t (c int) engine=MyISAM data directory="~/foo/bar";
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
@@ -132,7 +132,7 @@ int my_setwd(const char *dir, myf MyFlags)
|
||||
int test_if_hard_path(register const char *dir_name)
|
||||
{
|
||||
if (dir_name[0] == FN_HOMELIB && dir_name[1] == FN_LIBCHAR)
|
||||
return (home_dir != NullS && test_if_hard_path(home_dir));
|
||||
return (home_dir != NullS && home_dir != dir_name && test_if_hard_path(home_dir));
|
||||
if (dir_name[0] == FN_LIBCHAR)
|
||||
return (TRUE);
|
||||
#ifdef FN_DEVCHAR
|
||||
|
||||
Reference in New Issue
Block a user