summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>2021-05-10 09:10:22 (GMT)
committerGitHub <noreply@github.com>2021-05-10 09:10:22 (GMT)
commit45862f9f5ef5d3c9da37f35e4fe4b18618530cfa (patch)
treee4a51d5e8890370304d06f4cb2bfdd375f540098 /Python
parent8e8307d70bb9dc18cfeeed3277c076309b27515e (diff)
downloadcpython-45862f9f5ef5d3c9da37f35e4fe4b18618530cfa.zip
cpython-45862f9f5ef5d3c9da37f35e4fe4b18618530cfa.tar.gz
cpython-45862f9f5ef5d3c9da37f35e4fe4b18618530cfa.tar.bz2
Prevent access outside buffer (GH-26012)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index f745067..8e1c5bd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4794,8 +4794,10 @@ scan_back_to_entry_start(unsigned char *p) {
}
static inline unsigned char *
-skip_to_next_entry(unsigned char *p) {
- for (; (p[0]&128) == 0; p++);
+skip_to_next_entry(unsigned char *p, unsigned char *end) {
+ while (p < end && ((p[0] & 128) == 0)) {
+ p++;
+ }
return p;
}
@@ -4863,7 +4865,7 @@ get_exception_handler(PyCodeObject *code, int index)
parse_block(scan, &res);
return res;
}
- scan = skip_to_next_entry(scan);
+ scan = skip_to_next_entry(scan, end);
}
res.b_handler = -1;
return res;