A note for the community
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Problem
Current impl:
fn get_offset_reader_file_id(&self, offset: u16) -> u16 {
self.get_current_reader_file_id().wrapping_add(offset) % MAX_FILE_ID
}
Consider:
current = 65534, offset = 1, returns 0
65534.wrapping_add(1) % 65535
65535 % 65535
0
current = 65534, offset = 2, still returns 0
65534.wrapping_add(2) % 65535
0 % 65535
0
One way to fix:
fn get_offset_reader_file_id(&self, offset: u16) -> u16 {
let curr = u32::from(self.get_current_reader_file_id());
let off = u32::from(offset);
u16::try_from((curr + off) % u32::from(MAX_FILE_ID))
.expect("(_ % MAX_FILE_ID) always fits in u16")
}
This is also a likely root-cause of #19759
Configuration
Version
latest (v0.55.0)
Debug Output
Example Data
No response
Additional Context
No response
References
No response
A note for the community
Problem
Current impl:
Consider:
One way to fix:
This is also a likely root-cause of #19759
Configuration
Version
latest (v0.55.0)
Debug Output
Example Data
No response
Additional Context
No response
References
No response