Skip to content

avoid quadratic backtracking when parsing bracketed server names - #2489

Open
dxbjavid wants to merge 1 commit into
JSQLParser:masterfrom
dxbjavid:server-name-regex-backtracking
Open

avoid quadratic backtracking when parsing bracketed server names#2489
dxbjavid wants to merge 1 commit into
JSQLParser:masterfrom
dxbjavid:server-name-regex-backtracking

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

Server's SERVER_PATTERN lets the first capturing group consume backslashes, so a bracketed name that is full of backslashes but never closes (for example [a\a\a...) makes the matcher explore every possible split between the server and instance groups, and the matching cost grows roughly quadratically with the length of the string, which can stall a thread that builds a Server from an untrusted qualified name. Excluding the backslash separator from the first group removes that ambiguity so matching stays linear, while [server\instance] and plain [server] still split exactly as before. The added test builds a Server from a long crafted value and would previously time out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant