-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix MariaDB compressed event decoding panic #1049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
MariaDB version 10.5.25 (when binlog_row_metadata=FULL and compressed events are enabled)
https://mariadb.com/docs/server/clients-and-utilities/server-client-software/client-libraries/clientserver-protocol/replication-protocol/rows_event_v1v2-rows_compressed_event_v1
Unfortunately, I don't have a packet capture available.
Yes, a test case would be valuable, but I don't see a simple way to create one without spinning up a MariaDB instance. The issue specifically occurs with real MariaDB compressed events (MARIADB_UPDATE_ROWS_COMPRESSED_EVENT_V1) that contain actual compressed row data. |
It might be possible to create a |
There are some unit tests that hard-code the binlog event and process them, like If you find it's too hard for you to add tests, it's OK to leave this PR unchanged and I can help with adding tests soon. |
ping @krajcik Hi, just checking in - any updates on the tests? No pressure at all - I can merge this PR and add tests later if you're unavailable. |
Unfortunately, I don't have the capacity to work on tests right now. I apologize for that. I could potentially add them later, but I'm not sure when I'll have the time. |
Fixes a critical panic in MariaDB compressed event processing where
decodeString
function attempts to read beyond buffer bounds.Root cause: After decompressing MariaDB data in
DecodeData
, theposition offset (
pos
) from the original compressed buffer wasincorrectly used to read from the new decompressed buffer, causing slice
bounds errors.
Solution: Reset position to 0 after successful decompression since
the decompressed data should be read from the beginning.
Changes
pos = 0
after MariaDB data decompression inRowsEvent.DecodeData()
Error Details
Before fix:
panic: runtime error: slice bounds out of range [:53440] with capacity
8577
at github.com/go-mysql-org/go-mysql/replication.decodeString(row_even
t.go:1468)
at github.com/go-mysql-org/go-mysql/replication.decodeValue(row_event
.go:1408)
at github.com/go-mysql-org/go-mysql/replication.(*RowsEvent).DecodeDa
ta(row_event.go:1234)
After fix:
MARIADB_UPDATE_ROWS_COMPRESSED_EVENT_V1
eventsTechnical Details
The issue occurred because:
DecompressMariadbData()
replaces the originaldata
buffer withdecompressed content
pos
offset was calculated for the compressed bufferaccess
pos = 0
ensures reading starts from the beginning ofdecompressed data