Skip to content

MDEV-39198 Reject empty string for startup options to mariadbd#5246

Open
y2kwak wants to merge 1 commit into
MariaDB:mainfrom
y2kwak:MDEV-39198
Open

MDEV-39198 Reject empty string for startup options to mariadbd#5246
y2kwak wants to merge 1 commit into
MariaDB:mainfrom
y2kwak:MDEV-39198

Conversation

@y2kwak

@y2kwak y2kwak commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, empty value start up commands were accepted silently, configuring the variable to default value. This change adds an explicit empty-string check to reject startup options with empty values.

How can this PR be tested?

Before the change, --create-tmp-table-binlog-formats='' is accepted

> ./build/sql/mariadbd --datadir=./data --user=root --create-tmp-table-binlog-formats='' &

2026-04-22 18:03:10 0 [Note] Starting MariaDB 12.3.2-MariaDB source revision  server_uid eqtiwfxRtNmJ5Y8UE8JB3iQbx6w= as process 13800
2026-04-22 18:03:10 0 [Note] Help others discover MariaDB. Star it on GitHub: https://github.com/MariaDB/server
2026-04-22 18:03:10 0 [Note] InnoDB: Compressed tables use zlib 1.3.2
2026-04-22 18:03:10 0 [Note] InnoDB: Number of transaction pools: 1
2026-04-22 18:03:10 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2026-04-22 18:03:10 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2026-04-22 18:03:10 0 [Warning] mariadbd: io_uring_queue_init() failed with EPERM: sysctl kernel.io_uring_disabled has the value 2, or 1 and the user of the process is not a member of sysctl kernel.io_uring_group. (see man 2 io_uring_setup).
create_uring failed: falling back to libaio
2026-04-22 18:03:10 0 [Note] InnoDB: Using Linux native AIO
2026-04-22 18:03:10 0 [Note] InnoDB: innodb_buffer_pool_size_max=8388608m, innodb_buffer_pool_size=128m
2026-04-22 18:03:10 0 [Note] InnoDB: Completed initialization of buffer pool
2026-04-22 18:03:10 0 [Note] InnoDB: File system buffers for log disabled (block size=4096 bytes)
2026-04-22 18:03:10 0 [Note] InnoDB: End of log at LSN=231689
2026-04-22 18:03:10 0 [Note] InnoDB: Opened 3 undo tablespaces
2026-04-22 18:03:10 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2026-04-22 18:03:10 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2026-04-22 18:03:10 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2026-04-22 18:03:10 0 [Note] InnoDB: log sequence number 231689; transaction id 210
2026-04-22 18:03:10 0 [Note] InnoDB: Loading buffer pool(s) from /quick-rebuilds/data/ib_buffer_pool
2026-04-22 18:03:10 0 [Note] Plugin 'FEEDBACK' is disabled.
2026-04-22 18:03:10 0 [Note] InnoDB: Buffer pool(s) load completed at 260422 18:03:10
2026-04-22 18:03:10 0 [Note] Server socket created on IP: '0.0.0.0', port: '3306'.
2026-04-22 18:03:10 0 [Note] Server socket created on IP: '::', port: '3306'.
2026-04-22 18:03:10 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2026-04-22 18:03:10 0 [Note] ./build/sql/mariadbd: ready for connections.
Version: '12.3.2-MariaDB'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

...
MariaDB [(none)]> SELECT @@GLOBAL.create_tmp_table_binlog_formats;
+------------------------------------------+
| @@GLOBAL.create_tmp_table_binlog_formats |
+------------------------------------------+
| STATEMENT                                |
+------------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> SELECT @@SESSION.create_tmp_table_binlog_formats;
+-------------------------------------------+
| @@SESSION.create_tmp_table_binlog_formats |
+-------------------------------------------+
| STATEMENT                                 |
+-------------------------------------------+
1 row in set (0.000 sec)

After the change, an error is logged at start up.

> ./build/sql/mariadbd --datadir=./data --user=root --create-tmp-table-binlog-formats='' &
2026-04-22 18:07:58 0 [ERROR] ./build/sql/mariadbd: Error while setting value '' to 'create_tmp_table_binlog_formats'

MTR test case is added to existing 'mysqld_option_err' test.

Basing the PR against the correct MariaDB version

  •  This is a new feature and the PR is based against the latest MariaDB development branch.

Copyright

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. I am contributing on behalf of my employer Amazon Web Services, Inc.

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
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds validation to reject empty values for GET_SET options, along with corresponding test cases. The review feedback identifies a potential null pointer dereference in mysys/my_getopt.c where argument is dereferenced as argument[0] without checking if argument is NULL first.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread mysys/my_getopt.c
Comment on lines +877 to +881
if (!argument[0])
{
res= EXIT_ARGUMENT_INVALID;
goto ret;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Dereferencing argument without checking if it is NULL can lead to a segmentation fault if the option is processed without an argument. To prevent a potential null pointer dereference, ensure argument is validated before checking its first character. Note that validation logic for configuration variables should explicitly allow empty strings if they are considered valid or represent the default state, so we should only check for NULL here.

      if (!argument)
      {
        res= EXIT_ARGUMENT_INVALID;
        goto ret;
      }
References
  1. Validation logic for configuration variables should explicitly allow empty strings if they are considered valid or represent the default state.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jun 16, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

FYI, some tests are failing after your change, e.g.:

main.show_check                          w6 [ fail ]
        Test ended at 2026-06-15 19:28:26
CURRENT_TEST: main.show_check
Failed to start mysqld.1
mysqltest failed but provided no output
worker[06] > Restart  - not started
 - saving '/home/buildbot/aarch64-debian-11/build/mysql-test/var/6/log/main.show_check/' to '/home/buildbot/aarch64-debian-11/build/mysql-test/var/log/main.show_check/'
Retrying test main.show_check, attempt(2/3)...
***Warnings generated in error logs during shutdown after running tests: main.show_check
2026-06-15 19:28:26 0 [ERROR] /home/buildbot/aarch64-debian-11/build/sql/mariadbd: Error while setting value '' to 'myisam-recover-options'
2026-06-15 19:28:26 0 [ERROR] Parsing options for plugin 'MyISAM' failed. Disabling plugin
2026-06-15 19:28:26 0 [ERROR] Failed to initialize plugins.
2026-06-15 19:28:26 0 [ERROR] Aborting

Also, Since this is a bug fix, I'd suggest you consider fixing this into the lowest affected GA version, I'd guess 10.11 in this case. I'll leave the backport for the final reviewer to decide on (it might be risky), but IMHO it should be done.

@gkodinov gkodinov self-assigned this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants