-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-38010: Fix trailing garbage in master.info numeric fields #4764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ayush-jha123
wants to merge
1
commit into
MariaDB:10.11
Choose a base branch
from
ayush-jha123:fix-branch-10.11
base: 10.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+159
−22
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| include/master-slave.inc | ||
| [connection master] | ||
| connection slave; | ||
| include/stop_slave.inc | ||
| call mtr.add_suppression("Error reading master configuration"); | ||
| call mtr.add_suppression("Failed to initialize the master info structure"); | ||
| call mtr.add_suppression("error connecting to master"); | ||
| include/rpl_restart_server.inc [server_number=2] | ||
| connection slave; | ||
| # Verifying that trailing garbage causes parsing to fail. | ||
| # Rejection successful. | ||
| # Restoring the slave to original replication state | ||
| include/rpl_restart_server.inc [server_number=2] | ||
| CHANGE MASTER TO MASTER_HOST='MASTER_HOST', MASTER_PORT=MASTER_PORT, MASTER_USER='MASTER_USER'; | ||
| include/start_slave.inc | ||
| connection master; | ||
| include/rpl_end.inc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # | ||
| # MDEV-38010: Trailing garbage in master.info numeric fields leads to corruption. | ||
| # This test verifis that the server strictly validates numeric lines in master.info. | ||
| # If trailing non-whitespace characters are found, the line is rejected as corrupted. | ||
| # | ||
|
|
||
| --source include/master-slave.inc | ||
| --source include/have_binlog_format_mixed.inc | ||
|
|
||
| --connection slave | ||
|
|
||
| # Step1: Capture the current working replication state. | ||
| # We need these to restore a clean environment after we've intentionally | ||
| # "broken" the master.info file for the test. | ||
| --let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1) | ||
| --let $master_port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1) | ||
| --let $master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1) | ||
|
|
||
| --source include/stop_slave.inc | ||
|
|
||
| # Suppress the err we expect to see in the log during this test. | ||
| # The server will log these when it hits our new strict validation logic. | ||
| call mtr.add_suppression("Error reading master configuration"); | ||
| call mtr.add_suppression("Failed to initialize the master info structure"); | ||
| call mtr.add_suppression("error connecting to master"); | ||
|
|
||
| --let $MYSQLD_DATADIR= `select @@datadir` | ||
|
|
||
| # Step2: Simulate a corrupted master.info file. | ||
| # We manually rewrite the file with "garbage" appended to numeric fields | ||
| # (Port and Connect_Retry) to trigger the new validation check. | ||
| --remove_file $MYSQLD_DATADIR/master.info | ||
| --write_file $MYSQLD_DATADIR/master.info | ||
| 17 | ||
| master-bin.000001 | ||
| 4 | ||
| 127.0.0.1 | ||
| root | ||
|
|
||
| 3306abcdefghijklmnopqrstuvwxyz&10 | ||
| 60 | ||
| 0 | ||
| 0 | ||
|
|
||
|
|
||
|
|
||
| 0 | ||
|
|
||
| 60.000abcdefghijklm | ||
| 1 1 | ||
| EOF | ||
|
|
||
| # Step3: Restart the slave to force it to parse the corrupted file. | ||
| --let $rpl_server_number= 2 | ||
| --source include/rpl_restart_server.inc | ||
|
|
||
| --connection slave | ||
|
|
||
| --echo # Verifying that trailing garbage causes parsing to fail. | ||
| # If the fix works, the server should reject the bad port "3306abcdef..." | ||
| # This may lead to Master_Port being unset or the slave failing to show up. | ||
| --let $port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1) | ||
|
|
||
| if ($port != 3306) { | ||
| if ($port != No such row) { | ||
| if ($port != "") { | ||
| --echo Error: The garbage in master.info was accepted! Port evaluated to $port. | ||
| --die "Test failed: Fix is not preventing garbage parsing." | ||
| } | ||
| } | ||
| } | ||
| --echo # Rejection successful. | ||
|
|
||
| # Step4: Cleanup and Restoration. | ||
| # We remove the bad master.info and use CHANGE MASTER TO with our saved | ||
| # parameters to restore the slave to its original state. | ||
| --remove_file $MYSQLD_DATADIR/master.info | ||
|
|
||
| --echo # Restoring the slave to original replication state | ||
| --let $rpl_server_number= 2 | ||
| --source include/rpl_restart_server.inc | ||
|
|
||
| --replace_result $master_port MASTER_PORT $master_host MASTER_HOST $master_user MASTER_USER | ||
| --eval CHANGE MASTER TO MASTER_HOST='$master_host', MASTER_PORT=$master_port, MASTER_USER='$master_user' | ||
| --source include/start_slave.inc | ||
|
|
||
| --connection master | ||
| --source include/rpl_end.inc | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you need to assign something to *var here. Otherwise msan complains.