Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7af6eec

Browse files
committed
Merged revisions 65147 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r65147 | bob.ippolito | 2008-07-19 16:59:50 -0500 (Sat, 19 Jul 2008) | 1 line #3322: bounds checking for _json.scanstring ........
1 parent 1aea30a commit 7af6eec

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Modules/_json.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
236236
if (chunks == NULL) {
237237
goto bail;
238238
}
239+
if (end < 0 || len <= end) {
240+
PyErr_SetString(PyExc_ValueError, "end is out of bounds");
241+
goto bail;
242+
}
239243
while (1) {
240244
/* Find the end of the string or the next escape */
241245
Py_UNICODE c = 0;
@@ -246,7 +250,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
246250
break;
247251
}
248252
else if (strict && c <= 0x1f) {
249-
raise_errmsg("Invalid control character at", pystr, begin);
253+
raise_errmsg("Invalid control character at", pystr, next);
250254
goto bail;
251255
}
252256
}
@@ -401,6 +405,10 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
401405
if (chunks == NULL) {
402406
goto bail;
403407
}
408+
if (end < 0 || len <= end) {
409+
PyErr_SetString(PyExc_ValueError, "end is out of bounds");
410+
goto bail;
411+
}
404412
while (1) {
405413
/* Find the end of the string or the next escape */
406414
Py_UNICODE c = 0;
@@ -411,7 +419,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
411419
break;
412420
}
413421
else if (strict && c <= 0x1f) {
414-
raise_errmsg("Invalid control character at", pystr, begin);
422+
raise_errmsg("Invalid control character at", pystr, next);
415423
goto bail;
416424
}
417425
}

0 commit comments

Comments
 (0)