Title: Heap-buffer-overflow in the `hz` incremental decoder on a trailing `~` · Issue #157325 · python/cpython · GitHub
Open Graph Title: Heap-buffer-overflow in the `hz` incremental decoder on a trailing `~` · Issue #157325 · python/cpython
X Title: Heap-buffer-overflow in the `hz` incremental decoder on a trailing `~` · Issue #157325 · python/cpython
Description: Bug report Bug description: import codecs d = codecs.getincrementaldecoder('hz')() d.decode(b'~', False) d.decode(b'', True) ================================================================= ==1==ERROR: AddressSanitizer: heap-buffer-over...
Open Graph Description: Bug report Bug description: import codecs d = codecs.getincrementaldecoder('hz')() d.decode(b'~', False) d.decode(b'', True) ================================================================= ==1==E...
X Description: Bug report Bug description: import codecs d = codecs.getincrementaldecoder('hz')() d.decode(b'~', False) d.decode(b'', True) ================================================...
Opengraph URL: https://github.com/python/cpython/issues/157325
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Heap-buffer-overflow in the `hz` incremental decoder on a trailing `~`","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nimport codecs\nd = codecs.getincrementaldecoder('hz')()\nd.decode(b'~', False) \nd.decode(b'', True)\n```\n\n```\n=================================================================\n==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x5020000040d1 at pc 0xffff7feff068 bp 0xffffd608df50 sp 0xffffd608df40\nREAD of size 1 at 0x5020000040d1 thread T0\n #0 0xffff7feff064 in hz_decode Modules/cjkcodecs/_codecs_cn.c:417\n #1 0xffff7fe7426c in decoder_feed_buffer Modules/cjkcodecs/multibytecodec.c:921\n #2 0xffff7fe76238 in _multibytecodec_MultibyteIncrementalDecoder_decode_impl Modules/cjkcodecs/multibytecodec.c:1214\n #3 0xffff7fe76238 in _multibytecodec_MultibyteIncrementalDecoder_decode Modules/cjkcodecs/clinic/multibytecodec.c.h:395\n #4 0xaaaad3656320 in _PyObject_VectorcallTstate Include/internal/pycore_call.h:144\n #5 0xaaaad3656320 in PyObject_Vectorcall Objects/call.c:327\n #6 0xaaaad3ca1bc8 in _Py_VectorCallInstrumentation_StackRefSteal Python/ceval.c:768\n #7 0xaaaad33d1de8 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:1906\n #8 0xaaaad3cc0b1c in _PyEval_EvalFrame Include/internal/pycore_ceval.h:122\n #9 0xaaaad3cc0b1c in _PyEval_Vector Python/ceval.c:2174\n #10 0xaaaad3cc0b1c in PyEval_EvalCode Python/ceval.c:679\n #11 0xaaaad3ebfeb4 in run_mod Python/pythonrun.c:1509\n #12 0xaaaad3ec0d38 in _PyRun_File Python/pythonrun.c:1332\n #13 0xaaaad3ec4ffc in _PyRun_SimpleFile Python/pythonrun.c:544\n #14 0xaaaad3ec8dd0 in _PyRun_AnyFile Python/pythonrun.c:92\n #15 0xaaaad3f9390c in pymain_run_file_obj Modules/main.c:478\n #16 0xaaaad3f9390c in pymain_run_file Modules/main.c:494\n #17 0xaaaad3f9390c in pymain_run_python Modules/main.c:804\n #18 0xaaaad3f9390c in Py_RunMain Modules/main.c:891\n #19 0xaaaad3f95c38 in pymain_main Modules/main.c:921\n #20 0xaaaad3f95c38 in Py_BytesMain Modules/main.c:945\n #21 0xffff82c484c0 (/lib/aarch64-linux-gnu/libc.so.6+0x284c0) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)\n #22 0xffff82c48594 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28594) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)\n #23 0xaaaad343beec in _start (/src/cpython/python+0x183beec) (BuildId: eba909a3db0adabacf151d7dc3081dda7999191a)\n\n0x5020000040d1 is located 0 bytes after 1-byte region [0x5020000040d0,0x5020000040d1)\nallocated by thread T0 here:\n #0 0xffff835e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0xffff7fe76090 in _multibytecodec_MultibyteIncrementalDecoder_decode_impl Modules/cjkcodecs/multibytecodec.c:1201\n #2 0xffff7fe76090 in _multibytecodec_MultibyteIncrementalDecoder_decode Modules/cjkcodecs/clinic/multibytecodec.c.h:395\n #3 0xaaaad3656320 in _PyObject_VectorcallTstate Include/internal/pycore_call.h:144\n #4 0xaaaad3656320 in PyObject_Vectorcall Objects/call.c:327\n #5 0xaaaad3ca1bc8 in _Py_VectorCallInstrumentation_StackRefSteal Python/ceval.c:768\n #6 0xaaaad33d1de8 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:1906\n #7 0xaaaad3cc0b1c in _PyEval_EvalFrame Include/internal/pycore_ceval.h:122\n #8 0xaaaad3cc0b1c in _PyEval_Vector Python/ceval.c:2174\n #9 0xaaaad3cc0b1c in PyEval_EvalCode Python/ceval.c:679\n #10 0xaaaad3ebfeb4 in run_mod Python/pythonrun.c:1509\n #11 0xaaaad3ec0d38 in _PyRun_File Python/pythonrun.c:1332\n #12 0xaaaad3ec4ffc in _PyRun_SimpleFile Python/pythonrun.c:544\n #13 0xaaaad3ec8dd0 in _PyRun_AnyFile Python/pythonrun.c:92\n #14 0xaaaad3f9390c in pymain_run_file_obj Modules/main.c:478\n #15 0xaaaad3f9390c in pymain_run_file Modules/main.c:494\n #16 0xaaaad3f9390c in pymain_run_python Modules/main.c:804\n #17 0xaaaad3f9390c in Py_RunMain Modules/main.c:891\n #18 0xaaaad3f95c38 in pymain_main Modules/main.c:921\n #19 0xaaaad3f95c38 in Py_BytesMain Modules/main.c:945\n #20 0xffff82c484c0 (/lib/aarch64-linux-gnu/libc.so.6+0x284c0) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)\n #21 0xffff82c48594 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28594) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)\n #22 0xaaaad343beec in _start (/src/cpython/python+0x183beec) (BuildId: eba909a3db0adabacf151d7dc3081dda7999191a)\n\nSUMMARY: AddressSanitizer: heap-buffer-overflow Modules/cjkcodecs/_codecs_cn.c:417 in hz_decode\nShadow bytes around the buggy address:\n 0x502000003e00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd\n 0x502000003e80: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa\n 0x502000003f00: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa\n 0x502000003f80: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa\n 0x502000004000: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa\n=>0x502000004080: fa fa fd fa fa fa fd fa fa fa[01]fa fa fa fa fa\n 0x502000004100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x502000004180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x502000004200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x502000004280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x502000004300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\nShadow byte legend (one shadow byte represents 8 application bytes):\n Addressable: 00\n Partially addressable: 01 02 03 04 05 06 07\n Heap left redzone: fa\n Freed heap region: fd\n Stack left redzone: f1\n Stack mid redzone: f2\n Stack right redzone: f3\n Stack after return: f5\n Stack use after scope: f8\n Global redzone: f9\n Global init order: f6\n Poisoned by user: f7\n Container overflow: fc\n Array cookie: ac\n Intra object redzone: bb\n ASan internal: fe\n Left alloca redzone: ca\n Right alloca redzone: cb\n==1==ABORTING\n```\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157333\n* gh-158161\n* gh-158162\n* gh-158163\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/djarfluka","@type":"Person","name":"djarfluka"},"datePublished":"2026-09-11T15:03:15Z","url":"https://github.com/python/cpython/issues/157325"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4aca4622-fbc4-dd2a-13ff-d11994949539 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96BE:249C8E:3DA2E2:548532:6AECCD9F |
| html-safe-nonce | 83c528848265a869de996f36c5a69c2c8e442d5a1d002574fe58510c18b4077b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkJFOjI0OUM4RTozREEyRTI6NTQ4NTMyOjZBRUNDRDlGIiwidmlzaXRvcl9pZCI6IjU1NDAwOTc3NDMwNDEzODM4MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c4b283fa571a4af0deda5eb244834d0e8f29c9461c659d4f5978da4201e2d465 |
| hovercard-subject-tag | issue:5425825178 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/157325/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a217cd6e7a4ab00ac28aa1c8003a8a501b564fff36582b02110335001346c13/python/cpython/issues/157325 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a217cd6e7a4ab00ac28aa1c8003a8a501b564fff36582b02110335001346c13/python/cpython/issues/157325 |
| og:image:alt | Bug report Bug description: import codecs d = codecs.getincrementaldecoder('hz')() d.decode(b'~', False) d.decode(b'', True) ================================================================= ==1==E... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | djarfluka |
| hostname | github.com |
| expected-hostname | github.com |
| None | dc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db139f0bf57b59bf9a8c4abb0849924d6c6ca559 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width