8000 bpo-35214: Fix OOB memory access in unicode escape parser (GH-10506) · python/cpython@746b2d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 746b2d3

Browse files
authored
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"'
1 parent 00b137c commit 746b2d3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fixed an out of bounds memory access when parsing a truncated unicode
2+
escape sequence at the end of a string such as ``'\N'``. It would read
3+
one byte beyond the end of the memory allocation.

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6069,7 +6069,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
60696069
}
60706070

60716071
message = "malformed \\N character escape";
6072-
if (*s == '{') {
6072+
if (s < end && *s == '{') {
60736073
const char *start = ++s;
60746074
size_t namelen;
60756075
/* look for the closing brace */

0 commit comments

Comments
 (0)
0