[Python-checkins] r65147 - python/trunk/Modules/_json.c

bob.ippolito python-checkins at python.org
Sat Jul 19 23:59:50 CEST 2008


Author: bob.ippolito
Date: Sat Jul 19 23:59:50 2008
New Revision: 65147

Log:
#3322: bounds checking for _json.scanstring

Modified:
   python/trunk/Modules/_json.c

Modified: python/trunk/Modules/_json.c
==============================================================================
--- python/trunk/Modules/_json.c	(original)
+++ python/trunk/Modules/_json.c	Sat Jul 19 23:59:50 2008
@@ -235,6 +235,10 @@
     if (chunks == NULL) {
         goto bail;
     }
+    if (end < 0 || len <= end) {
+        PyErr_SetString(PyExc_ValueError, "end is out of bounds");
+        goto bail;
+    }
     while (1) {
         /* Find the end of the string or the next escape */
         Py_UNICODE c = 0;
@@ -245,7 +249,7 @@
                 break;
             }
             else if (strict && c <= 0x1f) {
-                raise_errmsg("Invalid control character at", pystr, begin);
+                raise_errmsg("Invalid control character at", pystr, next);
                 goto bail;
             }
         }
@@ -396,6 +400,10 @@
     if (chunks == NULL) {
         goto bail;
     }
+    if (end < 0 || len <= end) {
+        PyErr_SetString(PyExc_ValueError, "end is out of bounds");
+        goto bail;
+    }
     while (1) {
         /* Find the end of the string or the next escape */
         Py_UNICODE c = 0;
@@ -406,7 +414,7 @@
                 break;
             }
             else if (strict && c <= 0x1f) {
-                raise_errmsg("Invalid control character at", pystr, begin);
+                raise_errmsg("Invalid control character at", pystr, next);
                 goto bail;
             }
         }


More information about the Python-checkins mailing list