From 339f50d0ddc6efe6fc23c905522c29c4c3ea1cf3 Mon Sep 17 00:00:00 2001 From: Yewon Kwak Date: Wed, 22 Apr 2026 18:48:33 +0000 Subject: [PATCH] MDEV-39198 Reject empty string for startup options to mariadbd Add an explicit empty-string check to reject startup options with empty values. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license --- mysql-test/main/mysqld_option_err.result | 2 ++ mysql-test/main/mysqld_option_err.test | 11 +++++++++-- mysys/my_getopt.c | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result index c59d038a3965a..351c990c783f3 100644 --- a/mysql-test/main/mysqld_option_err.result +++ b/mysql-test/main/mysqld_option_err.result @@ -1,5 +1,7 @@ Test that unknown option is not silently ignored. Test bad binlog format. +Test empty value for GET_SET option is rejected. +FOUND 1 /Error while setting value '' to 'create_tmp_table_binlog_formats'/ in mysqltest.log Test bad default storage engine. Test non-numeric value passed to number option. Test with invalid path diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test index 2b98ef0fb9304..4f57b14f7280e 100644 --- a/mysql-test/main/mysqld_option_err.test +++ b/mysql-test/main/mysqld_option_err.test @@ -30,6 +30,15 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --log-bin --binlog-format=badformat >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--echo Test empty value for GET_SET option is rejected. +--error 13 +--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --create-tmp-table-binlog-formats='' >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + +--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log + +--let SEARCH_PATTERN=Error while setting value '' to 'create_tmp_table_binlog_formats' +--source include/search_pattern_in_file.inc + --echo Test bad default storage engine. --error 1 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --default-storage-engine=nonexistentengine >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 @@ -50,8 +59,6 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --error 1 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --plugin-maturity=experimental --plugin-load=example=ha_example --plugin-example=FORCE --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 ---let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log - --echo Test to see if multiple unknown options will be displayed in the error output --error 7 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption2 --alsononexistent --nonexistentvariable=1 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0a6bf530c49af..a98eeecd2c3c9 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -874,6 +874,11 @@ static int setval(const struct my_option *opts, void *value, char *argument, } break; case GET_SET: + if (!argument[0]) + { + res= EXIT_ARGUMENT_INVALID; + goto ret; + } *((ulonglong*)value)= find_typeset(argument, opts->typelib, &err); if (err) {