mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695)
This commit is contained in:
parent
ba8aa1fd37
commit
c8faa3568a
3 changed files with 53 additions and 3 deletions
|
|
@ -207,8 +207,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(codec, &c, &length);
|
||||
encoded = dsg->encoder(codec, buf, &length);
|
||||
if (encoded == MAP_MULTIPLE_AVAIL) {
|
||||
/* this implementation won't work for pair
|
||||
* of non-bmp characters. */
|
||||
|
|
@ -217,9 +218,11 @@ ENCODER(iso2022)
|
|||
return MBERR_TOOFEW;
|
||||
length = -1;
|
||||
}
|
||||
else
|
||||
else {
|
||||
buf[1] = INCHAR2;
|
||||
length = 2;
|
||||
encoded = dsg->encoder(codec, &c, &length);
|
||||
}
|
||||
encoded = dsg->encoder(codec, buf, &length);
|
||||
if (encoded != MAP_UNMAPPABLE) {
|
||||
insize = length;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue