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
de5f9f4f
Commit
de5f9f4f
authored
Sep 07, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise more correct exception on overflow in setting buffer_size attribute of
expat parser.
parent
931331a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
Lib/test/test_pyexpat.py
Lib/test/test_pyexpat.py
+3
-0
Modules/pyexpat.c
Modules/pyexpat.c
+7
-6
No files found.
Lib/test/test_pyexpat.py
View file @
de5f9f4f
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
from
io
import
BytesIO
from
io
import
BytesIO
import
os
import
os
import
sys
import
sysconfig
import
sysconfig
import
unittest
import
unittest
import
traceback
import
traceback
...
@@ -543,6 +544,8 @@ class ChardataBufferTest(unittest.TestCase):
...
@@ -543,6 +544,8 @@ class ChardataBufferTest(unittest.TestCase):
parser
.
buffer_size
=
-
1
parser
.
buffer_size
=
-
1
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
parser
.
buffer_size
=
0
parser
.
buffer_size
=
0
with
self
.
assertRaises
((
ValueError
,
OverflowError
)):
parser
.
buffer_size
=
sys
.
maxsize
+
1
with
self
.
assertRaises
(
TypeError
):
with
self
.
assertRaises
(
TypeError
):
parser
.
buffer_size
=
512.0
parser
.
buffer_size
=
512.0
...
...
Modules/pyexpat.c
View file @
de5f9f4f
...
@@ -1403,17 +1403,18 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
...
@@ -1403,17 +1403,18 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
return
-
1
;
return
-
1
;
}
}
new_buffer_size
=
PyLong_AS_LONG
(
v
);
new_buffer_size
=
PyLong_AsLong
(
v
);
if
(
new_buffer_size
<=
0
)
{
if
(
!
PyErr_Occurred
())
PyErr_SetString
(
PyExc_ValueError
,
"buffer_size must be greater than zero"
);
return
-
1
;
}
/* trivial case -- no change */
/* trivial case -- no change */
if
(
new_buffer_size
==
self
->
buffer_size
)
{
if
(
new_buffer_size
==
self
->
buffer_size
)
{
return
0
;
return
0
;
}
}
if
(
new_buffer_size
<=
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"buffer_size must be greater than zero"
);
return
-
1
;
}
/* check maximum */
/* check maximum */
if
(
new_buffer_size
>
INT_MAX
)
{
if
(
new_buffer_size
>
INT_MAX
)
{
char
errmsg
[
100
];
char
errmsg
[
100
];
...
...
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