diff options
author | Donghee Na <donghee.na@python.org> | 2023-11-06 11:29:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-06 11:29:59 (GMT) |
commit | bd4cc4715f425e557b2c707dca21dbf00897cef3 (patch) | |
tree | fc7e48f5c07b2d0b52d27196d53c77b62514b995 /Modules | |
parent | 9fe9eaec2d094a65eb106de447d2f5c9fd1ab267 (diff) | |
download | cpython-bd4cc4715f425e557b2c707dca21dbf00897cef3.zip cpython-bd4cc4715f425e557b2c707dca21dbf00897cef3.tar.gz cpython-bd4cc4715f425e557b2c707dca21dbf00897cef3.tar.bz2 |
[3.11] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 co… (gh-111771)
[3.11] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695)
(cherry picked from commit c8faa3568afd255708096f6aa8df0afa80cf7697)
Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/cjkcodecs/_codecs_iso2022.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c index 7394cf6..6d906ec 100644 --- a/Modules/cjkcodecs/_codecs_iso2022.c +++ b/Modules/cjkcodecs/_codecs_iso2022.c @@ -181,8 +181,9 @@ ENCODER(iso2022) encoded = MAP_UNMAPPABLE; for (dsg = CONFIG_DESIGNATIONS; dsg->mark; dsg++) { + Py_UCS4 buf[2] = {c, 0}; Py_ssize_t length = 1; - encoded = dsg->encoder(&c, &length); + encoded = dsg->encoder(buf, &length); if (encoded == MAP_MULTIPLE_AVAIL) { /* this implementation won't work for pair * of non-bmp characters. */ @@ -191,9 +192,11 @@ ENCODER(iso2022) return MBERR_TOOFEW; length = -1; } - else + else { + buf[1] = INCHAR2; length = 2; - encoded = dsg->encoder(&c, &length); + } + encoded = dsg->encoder(buf, &length); if (encoded != MAP_UNMAPPABLE) { insize = length; break; |