Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4e7457b8
Commit
4e7457b8
authored
May 09, 2017
by
Xiang Zhang
Committed by
GitHub
May 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-29990: Fix range checking in GB18030 decoder (#1509)
parent
228da429
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/test/test_codecencodings_cn.py
Lib/test/test_codecencodings_cn.py
+6
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/cjkcodecs/_codecs_cn.c
Modules/cjkcodecs/_codecs_cn.c
+3
-1
No files found.
Lib/test/test_codecencodings_cn.py
View file @
4e7457b8
...
...
@@ -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"
,
"
\
x81
9
\
xa7
9"
),
# 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
\
x30
def"
,
"replace"
,
u'abc
\
ufffd
def'
),
(
"abc
\
xbf
\
x38
\
xff
\
x32
\
xc1
\
xc4
"
,
"ignore"
,
u"abc
\
u804a
"
),
)
has_iso10646
=
True
...
...
Misc/NEWS
View file @
4e7457b8
...
...
@@ -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
.
...
...
Modules/cjkcodecs/_codecs_cn.c
View file @
4e7457b8
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment