]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Prevent access outside buffer (GH-26012)
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Mon, 10 May 2021 09:10:22 +0000 (05:10 -0400)
committerGitHub <noreply@github.com>
Mon, 10 May 2021 09:10:22 +0000 (10:10 +0100)
Python/ceval.c

index f7450670691dd1d7a9fe164110f46bc3e286c857..8e1c5bdf033074e9276f16ad4f6a2c5079480cc3 100644 (file)
@@ -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;