You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: COM_STMT_EXECUTE date-family decoding accepts or panics on truncated bodies #25756
Binary-protocol DATE, DATETIME, and TIMESTAMP parameter decoding does not validate that the declared temporal body is present before indexing it.
readDate, readDateTime, and readTimestamp perform unchecked indexing and ignore failed integer reads. A white-box short-packet test supplies every body length from zero through declared-length minus one for DATE(4), DATETIME(7), and TIMESTAMP(11). On latest main, malformed packets are either silently accepted with a nil error or panic with an index-out-of-range error.
The TIME(8)/TIME(12) bounds handling and TIME(12) position advancement originally included in this issue are already fixed on main by 5fe5e46fc9. A valid TIME(12) followed by another parameter now decodes correctly. This issue is therefore narrowed to the date-family helpers.
Expected Behavior
Any DATE, DATETIME, or TIMESTAMP body shorter than its declared binary-protocol length must return a malformed-packet error without panicking or consuming bytes outside that parameter.
Steps to Reproduce
Prepare select ?.
Bind each of DATE(4), DATETIME(7), and TIMESTAMP(11).
For each type, provide every body length from zero through declared-length minus one.
Assert parsing does not panic and returns an error.
On main@e538e203a, the test observes both nil errors and index-out-of-range panics.
changed the title [-][Bug]: COM_STMT_EXECUTE temporal decoding panics on truncation and misaligns TIME(12)[/-][+][Bug]: COM_STMT_EXECUTE date-family decoding accepts or panics on truncated bodies[/+]on Jul 15, 2026
Activity
[-][Bug]: COM_STMT_EXECUTE temporal decoding panics on truncation and misaligns TIME(12)[/-][+][Bug]: COM_STMT_EXECUTE date-family decoding accepts or panics on truncated bodies[/+]Ariznawlll commentedon Jul 15, 2026
main 分支复核
origin/main@e538e203ad47ebf0506a424fe93aed61290c40615fe5e46fc9修复,因此标题和正文已收窄为 date-family 问题。daviszhen commentedon Sep 21, 2026
#25756 (https://github.com/matrixorigin/matrixone/issues/25756)、#25744
(https://github.com/matrixorigin/matrixone/issues/25744)、#25743
(#25743) 均已由提交 e2c5dc0 / PR #25750
(e2c5dc0) 修复:
daviszhen commentedon Sep 21, 2026
本地 Docker 实测复核(2026-09-21):使用从当时最新
matrixorigin/main@df41cc24fc88fefab35151b494faa928c55eacb8构建的mo-service,直连 CN 的 MySQL 协议端口发送原始报文;已核对容器运行进程与构建产物的 SHA-256 一致。先用 COM_STMT_PREPARE 准备
select ?,再分别构造 DATE(4)、DATETIME(7)、TIMESTAMP(11) 的每一种截断 body(实际长度 0 到声明长度减 1,共 22 个 COM_STMT_EXECUTE)。22/22 均收到 MySQL ERR 20301:invalid input: mysql protocol error, malformed packet。CN 日志未发现越界 panic;测试后的新连接与 COM_PING 仍正常。结论:此 issue 描述的 date-family 截断问题在上述 main 提交上已无法复现。修复代码见 e2c5dc0 / PR #25750 的 temporal body 长度检查。本次验证范围是这 22 个截断输入,不代表覆盖其他参数类型。
Ariznawlll commentedon Sep 22, 2026
测试版本
main3727c5c5436ca136d7b0312f75bc223a11692a85原问题验证
COM_STMT_EXECUTE 对 DATE、DATETIME、TIMESTAMP 的截断二进制参数均返回协议错误,不再接受非法值或触发 panic。
Happy Path 覆盖
通过原始 MySQL handshake、COM_STMT_PREPARE 与 COM_STMT_EXECUTE 完成合法预处理语句生命周期,并在每次异常后以 COM_PING 验证连接可继续使用。
Unhappy Path 覆盖
覆盖 DATE(合法长度 4)、DATETIME(合法长度 7)、TIMESTAMP(合法长度 11)的全部截断长度,单轮共 66 个畸形包,全部返回 ERR。
白盒验证
测试直接构造 wire packet,不经过驱动的参数长度校验,能够命中服务端 date-family 解码边界;每个错误后检查 session 健康状态。
回归测试
新增
script/14_issue_regression/issue_25743_25744_25756_protocol_bounds.go及同名.sh入口,已提交至 motr#199。测试证据
协议场景连续执行 3 轮;本次新增 7 个 case 共执行 21 次,结果为
21/21通过。14_issue_regression整套执行时该场景也通过。MOTR 当前未为该分支上报远端 checks。测试结论
测试通过。