Repository navigation
Fix negative TIME(1)/TIME(2) with a fraction in the binlog decoder - #200
Open
panchenkoai wants to merge 1 commit into
Open
panchenkoai wants to merge 1 commit into
panchenkoai wants to merge 1 commit into
Conversation
my_time_packed_from_binary read the one-byte fraction of TIME(1)/TIME(2) as u32 and subtracted 0x100 for a negative value, which underflows: a panic with overflow checks, a wrap to about 625 hours without. The TIME(3)/TIME(4) arm already uses i32.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
my_time_packed_from_binary(src/binlog/misc.rs) reads the one-byte fraction of a TIME(1)/TIME(2) value asu32and, for a negative value with a fraction, runsfrac -= 0x100. The subtraction underflows: it panics with overflow checks on (debug), and wraps to a duration of about 625 hours with them off (release). The TIME(3)/TIME(4) arm just below already reads the fraction asi32.Minimal reproduction: a MySQL server with binlog_format=ROW, then
The row event carries the TIME2 bytes
7f ff ff ce(integer part -1, fraction byte 206). Without the change:With the change it returns
-500_000microseconds, andtime_from_packedgivesValue::Time(true, 0, 0, 0, 0, 500_000), which is what the server stored.The change reads the fraction as
i32and adds unit tests for negative TIME(1)/(2) with a fraction (-00:00:00.50,-00:00:01.25), the TIME(3)/(4) arm, and a positive value.The same line is present in v0.37.3 and v0.38.2.