[2.7] bpo-35214: Fix OOB memory access in unicode escape parser (GH-10506) (GH-10538)
Discovered using clang's MemorySanitizer.
A msan build will fail by simply executing: ./python -c 'u"\N"'
(cherry picked from commit 746b2d3
)
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
This commit is contained in:
parent
815fa49d10
commit
b6f4472dc4
|
@ -0,0 +1,3 @@
|
||||||
|
Fixed an out of bounds memory access when parsing a truncated unicode escape
|
||||||
|
sequence at the end of a string such as ``u'\N'``. It would read one byte
|
||||||
|
beyond the end of the memory allocation.
|
|
@ -2950,7 +2950,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
|
||||||
if (ucnhash_CAPI == NULL)
|
if (ucnhash_CAPI == NULL)
|
||||||
goto ucnhashError;
|
goto ucnhashError;
|
||||||
}
|
}
|
||||||
if (*s == '{') {
|
if (s < end && *s == '{') {
|
||||||
const char *start = s+1;
|
const char *start = s+1;
|
||||||
/* look for the closing brace */
|
/* look for the closing brace */
|
||||||
while (*s != '}' && s < end)
|
while (*s != '}' && s < end)
|
||||||
|
|
Loading…
Reference in New Issue