Skip to content

Fix and test out of range#1166

Merged
lance6716 merged 1 commit into
go-mysql-org:masterfrom
desdic:20260703outofrange
Jul 3, 2026
Merged

Fix and test out of range#1166
lance6716 merged 1 commit into
go-mysql-org:masterfrom
desdic:20260703outofrange

Conversation

@desdic

@desdic desdic commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

When sending a pluginname, username without a null termination it panics like
panic: runtime error: slice bounds out of range [58:57]

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request adds validation to ensure that NUL-terminated strings (username, database name, and auth plugin name) in the handshake response are properly terminated, returning an error if they are not. It also updates the corresponding tests. The reviewer recommended adding bounds checks (pos > len(data)) to prevent potential out-of-bounds panics, reusing the calculated index idx to avoid redundant bytes.IndexByte and len calls, and removing a duplicate test case in the test suite.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread server/handshake_resp.go Outdated
Comment thread server/handshake_resp.go Outdated
Comment thread server/handshake_resp.go Outdated
Comment thread server/handshake_resp_test.go Outdated
@desdic desdic force-pushed the 20260703outofrange branch 8 times, most recently from 7c19935 to 0caa5a6 Compare July 3, 2026 08:46

@lance6716 lance6716 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rest lgtm

Comment thread server/handshake_resp.go
Comment thread server/handshake_resp.go
When sending a pluginname, username without a null termination it panics
like
panic: runtime error: slice bounds out of range [58:57]
@desdic desdic force-pushed the 20260703outofrange branch from 0caa5a6 to 66e959e Compare July 3, 2026 10:51
@lance6716 lance6716 merged commit a57884f into go-mysql-org:master Jul 3, 2026
20 checks passed
dbnski pushed a commit to dbnski/go-mysql that referenced this pull request Jul 10, 2026
When sending a pluginname, username without a null termination it panics
like
panic: runtime error: slice bounds out of range [58:57]
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.

2 participants