-
Notifications
You must be signed in to change notification settings - Fork 589
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
fix: parsing the header of confluent protobuf message incorrectly #15444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
share the same impl with confluent https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/utils/ByteUtils.java#L159
let buffer = vec![0xFF, 0xFF, 0xFF, 0xFF, 0x0F]; | ||
let (value, len) = decode_variant_zigzag(&buffer).unwrap(); | ||
assert_eq!(value, i32::MIN); | ||
assert_eq!(len, 5); | ||
|
||
// 7. Invalid input (more than 5 bytes) | ||
let buffer = vec![0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if input is [0xFF, 0xFF, 0xFF, 0xFF, 0x7F]
? It is within 5 encoded bytes but more than 32 bits after decoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is i32::MIN, and the overflowed bits will be ignored. The behavior is the same as confluent's implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can test the original impl here.
https://www.sololearn.com/en/compiler-playground/ccEr3Q77KgqB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Resolve #14773.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.