Skip to content

MDEV-41498 CHANGE MASTER should reject null and line-break bytes - #6004

Open
Alokesh60 wants to merge 3 commits into
MariaDB:11.4from
Alokesh60:bb-11.4-MDEV-41498
Open

Alokesh60 wants to merge 3 commits into
MariaDB:11.4from
Alokesh60:bb-11.4-MDEV-41498

Conversation

@Alokesh60

Copy link
Copy Markdown

CHANGE MASTER string option values break when encountering null (\0) or line-break (\n) bytes because they are stored null-terminated in memory and as plain-text lines on disk.

This patch adds a validation block directly in the parser to explicitly reject strings containing \0 or \n for these options, immediately throwing ER_WRONG_ARGUMENTS (1210).

@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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 all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Alakesh Boro
❌ Alokesh60


Alakesh Boro seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Alokesh60
Alokesh60 force-pushed the bb-11.4-MDEV-41498 branch 2 times, most recently from bbeafe1 to fa662d0 Compare October 27, 2026 18:26
Comment thread sql/sql_yacc.yy Resolved
Comment thread sql/sql_yacc.yy Resolved
@ParadoxV5 ParadoxV5 added External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. Replication Patches involved in replication labels Oct 27, 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.

Please work through the CLA assistant. For it to be cleared the following things need to align:

  • you need have a github account
  • your github account needs to have your commit email that you've used

Please verify what of the above doesn't hold and then click the CLA button.
FWIW, I've seen your email to the mailing list. But there is a better way :)

Some more comments below.

Comment thread mysql-test/main/mdev_41498.test Resolved
Comment thread mysql-test/main/mdev_41498.test Resolved
Comment thread sql/sql_yacc.yy Resolved
Comment thread sql/sql_yacc.yy Resolved
Comment thread sql/sql_yacc.yy Resolved
@gkodinov gkodinov self-assigned this Oct 28, 2026
@Alokesh60
Alokesh60 force-pushed the bb-11.4-MDEV-41498 branch 2 times, most recently from b5efa54 to af3fcb6 Compare October 28, 2026 12:17
CHANGE MASTER string option values break when encountering null (\0) or line-break (\n) bytes because they are stored null-terminated in memory and as plain-text lines on disk.

This patch adds a validation block directly in the parser to explicitly reject strings containing \0 or \n for these options, immediately throwing ER_WRONG_ARGUMENTS (1210).
@Alokesh60

Copy link
Copy Markdown
Author

Hi @gkodinov, I've updated the PR based on the feedback:

Moved the validation logic out of the parser and into an inline helper function in sql_lex.h.

Renamed the new token to uppercase (TEXT_STRING_SYS_NO_LINEBREAK_NULL).

Moved the test cases into rpl_change_master.test and formatted the headers as requested.

Let me know if you need any further changes!

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

LGTM. Please stand by for the final review.

Comment thread sql/sql_yacc.yy Resolved
Comment thread sql/sql_yacc.yy Resolved
@gkodinov gkodinov assigned ParadoxV5 and unassigned gkodinov Oct 29, 2026
@gkodinov
gkodinov requested a review from ParadoxV5 October 29, 2026 11:15
@ParadoxV5

ParadoxV5 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Hi @gkodinov,
I can review this PR, but it and #5820 (MDEV-40271) should match the user-facing design, and no reviewer (@bnestere) has replied to me about the latter yet.
P.S. I’ll see if we have time to bring this pair up in tomorrow’s call.

--error ER_WRONG_ARGUMENTS
CHANGE MASTER TO MASTER_HOST='127.0\n.0.1';

--echo # Test 4: String with carriage return (\r) in the middle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In particular, although any control code is questionable when appearing in these strings, I don’t think \r and others actually break anything.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should I remove the check for \r and only restrict \n and \0, or keep it blocked just to be safe?

Comment thread sql/sql_lex.h Resolved
@Alokesh60
Alokesh60 force-pushed the bb-11.4-MDEV-41498 branch 2 times, most recently from 346f8d1 to 886985c Compare November 2, 2026 12:46
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. Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

4 participants