Skip to content

Commit 1ca970a

Browse files
committed
Bug#30908328 - Post-Fix
The MTR test meb.innodb_undo_directory uses a circular reference as an innodb-undo-directory. An ADD DATAFILE path is not allowed to contain circular references like "dir1/../dir2". Instead of changing the testcase, this changes the code to use the full path of the undo directory instead of the circular path. Approved in RB#24004 by Rahul
1 parent e4e3bfd commit 1ca970a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

storage/innobase/trx/trx0purge.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,15 @@ void Tablespace::set_file_name(const char *file_name) {
779779
/* Explicit undo tablespaces use an IBU extension. */
780780
m_implicit = (Fil_path::has_suffix(IBU, file_name) ? false : true);
781781

782-
size_t size_undo_dir = strlen(srv_undo_dir);
783-
size_t size_sep =
784-
srv_undo_dir[size_undo_dir - 1] == OS_PATH_SEPARATOR ? 0 : 1;
782+
/* We cannot allow a circular reference (has "..") in an ADD DATAFILE
783+
file name. So if srv_undo_dir is circular, use the full path. */
784+
const char *undo_dir = srv_undo_dir;
785+
if (MySQL_undo_path.is_circular()) {
786+
undo_dir = MySQL_undo_path.abs_path().c_str();
787+
}
788+
789+
size_t size_undo_dir = strlen(undo_dir);
790+
size_t size_sep = undo_dir[size_undo_dir - 1] == OS_PATH_SEPARATOR ? 0 : 1;
785791

786792
/* Make a copy of the filename and normalize it. */
787793
char fn[FN_REFLEN];
@@ -793,7 +799,7 @@ void Tablespace::set_file_name(const char *file_name) {
793799
ADD DATAFILE for undo tablespaces does not accept a relative path.
794800
If a relative path comes in here, it was the scanned name and is
795801
relative to the datadir.
796-
So only prepend the srv_undo_dir if this is just a basename. */
802+
So only prepend the undo_dir if this is just a basename. */
797803
char *sep = strchr(fn, OS_PATH_SEPARATOR);
798804
char *col = strchr(fn, ':');
799805
if (sep != nullptr || col != nullptr) {
@@ -806,7 +812,7 @@ void Tablespace::set_file_name(const char *file_name) {
806812

807813
char *ptr = m_file_name;
808814
if (size_undo_dir > 0) {
809-
memcpy(ptr, srv_undo_dir, size_undo_dir);
815+
memcpy(ptr, undo_dir, size_undo_dir);
810816
ptr += size_undo_dir;
811817
}
812818
if (size_sep > 0) {

0 commit comments

Comments
 (0)