]> granicus.if.org Git - python/commitdiff
Issue #16335: Fix integer overflow in unicode-escape decoder.
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 21 Jan 2013 09:42:57 +0000 (11:42 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 21 Jan 2013 09:42:57 +0000 (11:42 +0200)
1  2 
Lib/test/test_ucn.py
Objects/unicodeobject.c

index 68a3219560e11d3d6e4cc1897ded45bca37f916a,de36cc366f066ab86ea6d1e8d6b45f7efe15e65d..ff4c4f1700fc3a43e176a99b9e0c6c09a4261636
@@@ -8,11 -8,9 +8,12 @@@ Modified for Python 2.0 by Fredrik Lund
  """#"
  
  import unittest
 +import unicodedata
+ import _testcapi
  
  from test import support
 +from http.client import HTTPException
 +from test.test_normalization import check_version
  
  class UnicodeNamesTest(unittest.TestCase):
  
index b57a8963b9d7f271b1e95322ca5b665647f825d3,ddd8d5307616a06fb41aacac43413a497d5aba4b..c30245d9f82fa0785dd1102539ceaf98415314cd
@@@ -5696,8 -3923,8 +5696,9 @@@ PyUnicode_DecodeUnicodeEscape(const cha
                      /* found a name.  look it up in the unicode database */
                      message = "unknown Unicode character name";
                      s++;
-                     if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1),
+                     if (s - start - 1 <= INT_MAX &&
 -                        ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr))
++                        ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1),
 +                                              &chr, 0))
                          goto store;
                  }
              }