[Python-checkins] cpython: Issue #27056: Fix _Unpickler_Read() to avoid integer overflow

victor.stinner python-checkins at python.org
Fri May 20 15:17:47 EDT 2016


https://hg.python.org/cpython/rev/3d7b7aa89437
changeset:   101453:3d7b7aa89437
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri May 20 21:16:59 2016 +0200
summary:
  Issue #27056: Fix _Unpickler_Read() to avoid integer overflow

files:
  Modules/_pickle.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1244,7 +1244,7 @@
    Returns -1 (with an exception set) on failure. On success, return the
    number of chars read. */
 #define _Unpickler_Read(self, s, n) \
-    (((self)->next_read_idx + (n) <= (self)->input_len)      \
+    (((n) <= (self)->input_len - (self)->next_read_idx)      \
      ? (*(s) = (self)->input_buffer + (self)->next_read_idx, \
         (self)->next_read_idx += (n),                        \
         (n))                                                 \

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list