Commit 6a8d02e
committed
bound binary-protocol datetime/time parameter reads to the declared length
get_param_length() guarantees only `length` bytes for a prepared-statement
parameter value sent over the binary protocol. set_param_datetime() reads
to[4..6] when length > 4 (needs 7 bytes) and sint4korr(to+7) when length > 7
(needs 11); set_param_time() reads sint4korr(to+8) when length > 8 (needs 12).
A client that sends an off-spec datetime length of 5, 6, 8, 9 or 10, or a
time length of 9, 10 or 11, makes the server read up to 3 bytes past the
validated value, an out-of-bounds read when the value ends at the packet
buffer boundary.
Gate the optional time and microsecond reads on the canonical encoding
lengths (>= 7 and >= 11 for datetime, >= 12 for time) so a short value falls
back to the next-shorter form instead of over-reading. Well-formed values
(datetime 4/7/11, time 8/12) parse exactly as before.1 parent 8eda901 commit 6a8d02e
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
610 | | - | |
| 610 | + | |
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | | - | |
| 619 | + | |
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
| |||
0 commit comments