Skip to content

Commit a7d3bc2

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 <jansturm92@googlemail.com>
1 parent c0afff8 commit a7d3bc2

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy