Browse Source
[3.10] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (GH-134345)
[3.10] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (GH-134345)
If the error handler is used, a new bytes object is created to set as the object attribute of UnicodeDecodeError, and that bytes object then replaces the original data. A pointer to the decoded data will became invalid after destroying that temporary bytes object. So we need other way to return the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal(). _PyBytes_DecodeEscape() does not have such issue, because it does not use the error handlers registry, but it should be changed for compatibility with _PyUnicode_DecodeUnicodeEscapeInternal(). (cherry picked from commitpull/135079/head9f69a58623
) (cherry picked from commit6279eb8c07
) (cherry picked from commita75953b347
) (cherry picked from commit0c33e5baed
) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 164 additions and 41 deletions
-
4Include/cpython/bytesobject.h
-
13Include/cpython/unicodeobject.h
-
36Lib/test/test_codeccallbacks.py
-
39Lib/test/test_codecs.py
-
2Misc/NEWS.d/next/Security/2025-05-09-20-22-54.gh-issue-133767.kN2i3Q.rst
-
40Objects/bytesobject.c
-
45Objects/unicodeobject.c
-
26Parser/string_parser.c
@ -0,0 +1,2 @@ |
|||
Fix use-after-free in the "unicode-escape" decoder with a non-"strict" error |
|||
handler. |
Write
Preview
Loading…
Cancel
Save
Reference in new issue