File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,13 @@ create table `#mysql50#q.q` select 1;
10
10
ERROR 42000: Incorrect table name '#mysql50#q.q'
11
11
create table `#mysql50#q·q` select 1;
12
12
drop database `b`;
13
+ #
14
+ # MDEV-27336 Crash on DROP DATABASE due to out-of-bounds result
15
+ # from InnoDB SUBSTR() function
16
+ #
17
+ USE test;
18
+ CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
19
+ CREATE TABLE t2(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
20
+ CREATE DATABASE somewhat_longer_name_to_cause_trouble;
21
+ DROP DATABASE somewhat_longer_name_to_cause_trouble;
22
+ DROP TABLE t2,t1;
Original file line number Diff line number Diff line change @@ -14,3 +14,14 @@ use `b`;
14
14
create table `#mysql50#q.q` select 1;
15
15
create table `#mysql50#q·q` select 1;
16
16
drop database `b`;
17
+
18
+ --echo #
19
+ --echo # MDEV-27336 Crash on DROP DATABASE due to out-of-bounds result
20
+ --echo # from InnoDB SUBSTR() function
21
+ --echo #
22
+ USE test;
23
+ CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
24
+ CREATE TABLE t2(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
25
+ CREATE DATABASE somewhat_longer_name_to_cause_trouble;
26
+ DROP DATABASE somewhat_longer_name_to_cause_trouble;
27
+ DROP TABLE t2,t1;
Original file line number Diff line number Diff line change 1
1
/* ****************************************************************************
2
2
3
3
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
4
- Copyright (c) 2019, MariaDB Corporation.
4
+ Copyright (c) 2019, 2021, MariaDB Corporation.
5
5
6
6
This program is free software; you can redistribute it and/or modify it under
7
7
the terms of the GNU General Public License as published by the Free Software
@@ -378,12 +378,23 @@ eval_substr(
378
378
379
379
str1 = static_cast <byte*>(dfield_get_data (que_node_get_val (arg1)));
380
380
381
+ const ulint str1_len = dfield_get_len (que_node_get_val (arg1));
382
+
381
383
len1 = (ulint) eval_node_get_int_val (arg2);
382
384
len2 = (ulint) eval_node_get_int_val (arg3);
383
385
384
386
dfield = que_node_get_val (func_node);
385
387
386
- dfield_set_data (dfield, str1 + len1, len2);
388
+ if (len1 > str1_len) {
389
+ len2 = 0 ;
390
+ } else {
391
+ str1 += len1;
392
+ if (len2 > str1_len - len1) {
393
+ len2 = str1_len - len1;
394
+ }
395
+ }
396
+
397
+ dfield_set_data (dfield, str1, len2);
387
398
}
388
399
389
400
/* ****************************************************************/ /* *
You can’t perform that action at this time.
0 commit comments