Fix bounds checks in BMI270 driver in bulk_read #161

Closed
opened 2026-04-05 17:52:02 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jabberrock on 11/11/2024

Both i and bytes_to_read are size_t, which are unsigned long. i - bytes_to_read always underflows and should have been bytes_to_read - i for how many bytes are left in the buffer. But since we're dealing with unsigned values, it's safer to only do additions and comparisons.

*Originally created by @jabberrock on 11/11/2024* Both `i` and `bytes_to_read` are `size_t`, which are `unsigned long`. `i - bytes_to_read` always underflows and should have been `bytes_to_read - i` for how many bytes are left in the buffer. But since we're dealing with unsigned values, it's safer to only do additions and comparisons.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/SlimeVR-Tracker-ESP#161