Repository navigation
Conversation
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.
Does your PR solve an issue?
fixes #4491
Is this a breaking change?
No.
SET NAMES 'charset' [COLLATE 'collation']with quoted string literals is valid MySQL syntax with identical semantics to the unquoted form; the generated statement only differs in quoting.charset,collationandtime_zonecome from the connection URL (or the builder methods) and were interpolated into the connect-timeSETstatement without quoting (charset/collationnot quoted at all,time_zonewrapped in single quotes but not escaped). Since the connection enablesCLIENT_MULTI_STATEMENTS, a crafted value liketime_zone='; <arbitrary SQL>; --could inject a second statement.This quotes all three as MySQL string literals via a new
quote_string_literal()helper (single quotes are doubled, backslashes escaped), and extracts statement building intoMySqlConnectOptions::connect_init_statement()so it can be unit-tested without a live connection.How verified:
cargo test -p sqlx-mysql --lib options::: 12 passed, 0 failed.cargo fmt --checkclean;cargo clippy --all-targetsclean for the touched file.