Skip to content

[Bug]: prepared binary protocol mishandles send-long-data chunks and truncated execute packets #23979

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

e65885f

Other Environment Information

  • Hardware parameters:
  • OS type: Linux
  • Others:

Actual Behavior

Two independent prepared-statement binary protocol problems remain on main:

  1. Repeated COM_STMT_SEND_LONG_DATA chunks for the same parameter overwrite the previous chunk instead of appending to it.
  2. COM_STMT_EXECUTE can panic on truncated packets because it reads the new parameter bound flag via data[pos] without a bounds check after consuming the null bitmap.

Expected Behavior

  • Repeated COM_STMT_SEND_LONG_DATA packets for the same parameter should append data, matching MySQL protocol semantics.
  • Truncated COM_STMT_EXECUTE packets should be rejected as malformed input instead of panicking.

Steps to Reproduce

1. Repeated COM_STMT_SEND_LONG_DATA overwrites instead of appending

Prepare a statement with one large text/blob parameter, then send two COM_STMT_SEND_LONG_DATA packets for the same parameter before COM_STMT_EXECUTE.

Expected final parameter value: concatenation of both chunks.

Actual value on main: only the last chunk is kept.

2. Truncated COM_STMT_EXECUTE can panic

Send a COM_STMT_EXECUTE payload that contains:

  • statement id
  • cursor flag
  • iteration count
  • complete null bitmap
  • no new parameter bound flag byte

Actual behavior on main: parser can panic when evaluating data[pos].

Expected behavior: return a malformed-packet error.

Additional information

Local focused regression coverage for the fix:

  • TestParseExecuteDataRejectsTruncatedNewParamBoundFlag
  • TestParseSendLongDataAppendsRepeatedChunks
  • Test_parseStmtSendLongData

Activity

  1. self-assigned this
    on Mar 27, 2026
  2. added
    kind/bug
    severity/s0
    on Mar 27, 2026
  3. added theissue type on Mar 27, 2026
  4. added this to the MO-202603 milestone on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions