Commit 746b2d35 authored by Gregory P. Smith's avatar Gregory P. Smith Committed by GitHub

bpo-35214: Fix OOB memory access in unicode escape parser (GH-10506)

Discovered using clang's MemorySanitizer when it ran python3's
test_fstring test_misformed_unicode_character_name.

An msan build will fail by simply executing: ./python -c 'u"\N"'
parent 00b137c7
Fixed an out of bounds memory access when parsing a truncated unicode
escape sequence at the end of a string such as ``'\N'``. It would read
one byte beyond the end of the memory allocation.
......@@ -6069,7 +6069,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
}
message = "malformed \\N character escape";
if (*s == '{') {
if (s < end && *s == '{') {
const char *start = ++s;
size_t namelen;
/* look for the closing brace */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment