MDEV-38010: Fix trailing garbage in master.info numeric fields#4764
Open
ayush-jha123 wants to merge 1 commit intoMariaDB:10.11from
Open
MDEV-38010: Fix trailing garbage in master.info numeric fields#4764ayush-jha123 wants to merge 1 commit intoMariaDB:10.11from
ayush-jha123 wants to merge 1 commit intoMariaDB:10.11from
Conversation
Modified init_intvar_from_file and init_floatvar_from_file to detect and reject trailing garbage in master.info numeric fields. Added a test case to verify the fix and ensure replication is correctly restored.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've updated this PR to target the 10.11 branch as requested and added a test case to verify the fix.
The issue was that
init_intvar_from_file
and
init_floatvar_from_file
were using atoi or simple sscanf, which would stop parsing at the first non-numeric character and leave the remaining "garbage" in the buffer. This garbage then corrupted the start of the next line.
I've changed the logic to use strtol and sscanf with %n to track exactly where parsing ends. Now, the code checks the rest of the line; if there's any non-whitespace characters left (like 3306abcdef), it returns an error instead of proceeding with a broken configuration.
The new MTR test main.mdev_38010 simulates a malformed master.info and confirms the server fails to load it, falling back to default values instead of accepting junk data.