Skip to content

Commit 7e1098b

Browse files
jansturm92dpgeorge
authored andcommitted
py/objdeque: Fix buffer overflow in deque_subscr.
In `deque_subscr()`, if `index_val` equals `self->alloc`, the index correction `index_val -= self->alloc` does not execute, leading to an out-of-bounds access in `self->items[index_val]`. The fix in this commit ensures that the index correction is applied whenever `index_val >= self->alloc`, preventing access beyond the allocated buffer size. Signed-off-by: Jan Sturm <[email protected]>
1 parent 0e490b7 commit 7e1098b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/objdeque.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static mp_obj_t deque_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
208208

209209
size_t offset = mp_get_index(self->base.type, deque_len(self), index, false);
210210
size_t index_val = self->i_get + offset;
211-
if (index_val > self->alloc) {
211+
if (index_val >= self->alloc) {
212212
index_val -= self->alloc;
213213
}
214214

0 commit comments

Comments
 (0)