X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/test/test_codecencodings_cn.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"),
("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"),
(u"\u30fb", "strict", "\x819\xa79"),
# issue29990
("\xff\x30\x81\x30", "strict", None),
("\x81\x30\xff\x30", "strict", None),
("abc\x81\x39\xff\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"),
("abc\xab\x36\xff\x30def", "replace", u'abc\ufffddef'),
("abc\xbf\x38\xff\x32\xc1\xc4", "ignore", u"abc\u804a"),
)
has_iso10646 = True

Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Extension Modules
Library
-------

- bpo-29990: Fix range checking in GB18030 decoder. Original patch by Ma Lin.

- bpo-30243: Removed the __init__ methods of _json's scanner and encoder.
Misusing them could cause memory leaks or crashes. Now scanner and encoder
objects are completely initialized in the __new__ methods.
Expand Down
4 changes: 3 additions & 1 deletion Modules/cjkcodecs/_codecs_cn.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ DECODER(gb18030)
REQUIRE_INBUF(4)
c3 = IN3;
c4 = IN4;
if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39)
if (c < 0x81 || c > 0xFE ||
c3 < 0x81 || c3 > 0xFE ||
c4 < 0x30 || c4 > 0x39)
return 4;
c -= 0x81; c2 -= 0x30;
c3 -= 0x81; c4 -= 0x30;
Expand Down
X Tutup