[Python-checkins] Prevent access outside buffer (GH-26012)

markshannon webhook-mailer at python.org
Mon May 10 05:10:49 EDT 2021


https://github.com/python/cpython/commit/45862f9f5ef5d3c9da37f35e4fe4b18618530cfa
commit: 45862f9f5ef5d3c9da37f35e4fe4b18618530cfa
branch: main
author: Dennis Sweeney <36520290+sweeneyde at users.noreply.github.com>
committer: markshannon <mark at hotpy.org>
date: 2021-05-10T10:10:22+01:00
summary:

Prevent access outside buffer (GH-26012)

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index f7450670691dd..8e1c5bdf03307 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;



More information about the Python-checkins mailing list