mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
MDEV-36230 Fix SERVER port field bound check
The Port field in the system table mysql.servers has type INT, which translates to Field_long. During parsing it is parsed as ulong_num, and in this patch we add bound checks there.
This commit is contained in:
parent
6f2a99589b
commit
8070033e47
3 changed files with 58 additions and 0 deletions
|
|
@ -104,4 +104,26 @@ uninstall soname "ha_example";
|
|||
ERROR HY000: Cannot load from mysql.plugin. The table is probably corrupted
|
||||
drop table mysql.plugin;
|
||||
rename table mysql.plugin_save to mysql.plugin;
|
||||
#
|
||||
# MDEV-36230 SIGSEGV in store_server_fields on CREATE SERVER
|
||||
#
|
||||
## Error code depends on length of long
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 4294967295);
|
||||
ERROR 22003: port value is out of range in 'INT'
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483647);
|
||||
select * from mysql.servers;
|
||||
Server_name Host Db Username Password Port Socket Wrapper Owner
|
||||
s 2147483647 mysql
|
||||
ALTER SERVER s OPTIONS (PORT 4294967295);
|
||||
ERROR 22003: port value is out of range in 'INT'
|
||||
select * from mysql.servers;
|
||||
Server_name Host Db Username Password Port Socket Wrapper Owner
|
||||
s 2147483647 mysql
|
||||
drop server s;
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483648);
|
||||
ERROR 22003: port value is out of range in 'INT'
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 18446744073709551615);
|
||||
ERROR 22003: port value is out of range in 'INT'
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT -5);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-5)' at line 1
|
||||
# End of 10.11 tests
|
||||
|
|
|
|||
|
|
@ -112,4 +112,24 @@ uninstall soname "ha_example";
|
|||
drop table mysql.plugin;
|
||||
rename table mysql.plugin_save to mysql.plugin;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-36230 SIGSEGV in store_server_fields on CREATE SERVER
|
||||
--echo #
|
||||
--echo ## Error code depends on length of long
|
||||
--error ER_DATA_OUT_OF_RANGE
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 4294967295);
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483647);
|
||||
select * from mysql.servers;
|
||||
--error ER_DATA_OUT_OF_RANGE
|
||||
ALTER SERVER s OPTIONS (PORT 4294967295);
|
||||
select * from mysql.servers;
|
||||
drop server s;
|
||||
--error ER_DATA_OUT_OF_RANGE
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483648);
|
||||
--error ER_DATA_OUT_OF_RANGE
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 18446744073709551615);
|
||||
--error ER_PARSE_ERROR
|
||||
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT -5);
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
|
|
|
|||
|
|
@ -2873,6 +2873,22 @@ server_option:
|
|||
}
|
||||
| PORT_SYM ulong_num
|
||||
{
|
||||
/*
|
||||
We especially don't want this to happen:
|
||||
|
||||
The value of $2 is ULONG_MAX, causing
|
||||
server_options.port to be -1, which means "default
|
||||
port".
|
||||
|
||||
Because we are doing a check here, we may as well check
|
||||
against the SQL data type in one go rather than just the
|
||||
C++ type here and SQL type later in sql_servers.cc.
|
||||
*/
|
||||
if ($2 > INT32_MAX)
|
||||
{
|
||||
my_error(ER_DATA_OUT_OF_RANGE, myf(0), "port", "INT");
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
Lex->server_options.port= $2;
|
||||
}
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue