diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-05-09 04:16:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-09 04:16:50 (GMT) |
commit | 72e1b61da0920c5607481304879e039b63e2a3d5 (patch) | |
tree | 52f1ec56a43f60681bdcaf3efa945716e101dd3e /Modules/cjkcodecs | |
parent | 410d75ab71e2db0fdc8b2016600a3d3d4830f38e (diff) | |
download | cpython-72e1b61da0920c5607481304879e039b63e2a3d5.zip cpython-72e1b61da0920c5607481304879e039b63e2a3d5.tar.gz cpython-72e1b61da0920c5607481304879e039b63e2a3d5.tar.bz2 |
bpo-29990: Fix range checking in GB18030 decoder (#1495) (#1507)
When decoding a 4-byte GB18030 sequence, the first and third byte cannot exceed 0xFE.
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r-- | Modules/cjkcodecs/_codecs_cn.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/cjkcodecs/_codecs_cn.c b/Modules/cjkcodecs/_codecs_cn.c index 1a070f2..bda175c 100644 --- a/Modules/cjkcodecs/_codecs_cn.c +++ b/Modules/cjkcodecs/_codecs_cn.c @@ -279,7 +279,9 @@ DECODER(gb18030) REQUIRE_INBUF(4); c3 = INBYTE3; c4 = INBYTE4; - if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39) + if (c < 0x81 || c > 0xFE || + c3 < 0x81 || c3 > 0xFE || + c4 < 0x30 || c4 > 0x39) return 1; c -= 0x81; c2 -= 0x30; c3 -= 0x81; c4 -= 0x30; |