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
1d1d3e9d
Commit
1d1d3e9d
authored
Aug 20, 2017
by
Oren Milman
Committed by
Serhiy Storchaka
Aug 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal tuples. (#3119)
parent
4bfebc63
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
19 deletions
+67
-19
Lib/test/test_audioop.py
Lib/test/test_audioop.py
+4
-0
Lib/test/test_io.py
Lib/test/test_io.py
+1
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+3
-1
Modules/_io/textio.c
Modules/_io/textio.c
+8
-1
Modules/audioop.c
Modules/audioop.c
+23
-7
Modules/overlapped.c
Modules/overlapped.c
+7
-2
Modules/socketmodule.c
Modules/socketmodule.c
+4
-2
Modules/timemodule.c
Modules/timemodule.c
+17
-6
No files found.
Lib/test/test_audioop.py
View file @
1d1d3e9d
...
...
@@ -405,6 +405,10 @@ class TestAudioop(unittest.TestCase):
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
,
30
,
10
)[
0
],
expected
[
w
])
self
.
assertRaises
(
TypeError
,
audioop
.
ratecv
,
b''
,
1
,
1
,
8000
,
8000
,
42
)
self
.
assertRaises
(
TypeError
,
audioop
.
ratecv
,
b''
,
1
,
1
,
8000
,
8000
,
(
1
,
(
42
,)))
def
test_reverse
(
self
):
for
w
in
1
,
2
,
3
,
4
:
self
.
assertEqual
(
audioop
.
reverse
(
b''
,
w
),
b''
)
...
...
Lib/test/test_io.py
View file @
1d1d3e9d
...
...
@@ -3472,6 +3472,7 @@ class IncrementalNewlineDecoderTest(unittest.TestCase):
decoder
=
codecs
.
getincrementaldecoder
(
"utf-8"
)()
decoder
=
self
.
IncrementalNewlineDecoder
(
decoder
,
translate
=
True
)
self
.
check_newline_decoding_utf8
(
decoder
)
self
.
assertRaises
(
TypeError
,
decoder
.
setstate
,
42
)
def
test_newline_bytes
(
self
):
# Issue 5433: Excessive optimization in IncrementalNewlineDecoder
...
...
Modules/_ctypes/_ctypes.c
View file @
1d1d3e9d
...
...
@@ -3262,7 +3262,9 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* Here ftuple is a borrowed reference */
return
NULL
;
if
(
!
PyArg_ParseTuple
(
ftuple
,
"O&O"
,
_get_name
,
&
name
,
&
dll
))
{
if
(
!
PyArg_ParseTuple
(
ftuple
,
"O&O;illegal func_spec argument"
,
_get_name
,
&
name
,
&
dll
))
{
Py_DECREF
(
ftuple
);
return
NULL
;
}
...
...
Modules/_io/textio.c
View file @
1d1d3e9d
...
...
@@ -562,8 +562,15 @@ _io_IncrementalNewlineDecoder_setstate(nldecoder_object *self,
PyObject
*
buffer
;
unsigned
long
long
flag
;
if
(
!
PyArg_ParseTuple
(
state
,
"OK"
,
&
buffer
,
&
flag
))
if
(
!
PyTuple_Check
(
state
))
{
PyErr_SetString
(
PyExc_TypeError
,
"state argument must be a tuple"
);
return
NULL
;
}
if
(
!
PyArg_ParseTuple
(
state
,
"OK;setstate(): illegal state argument"
,
&
buffer
,
&
flag
))
{
return
NULL
;
}
self
->
pendingcr
=
(
int
)
(
flag
&
1
);
flag
>>=
1
;
...
...
Modules/audioop.c
View file @
1d1d3e9d
...
...
@@ -1293,7 +1293,7 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
char
*
cp
,
*
ncp
;
Py_ssize_t
len
;
int
chan
,
d
,
*
prev_i
,
*
cur_i
,
cur_o
;
PyObject
*
samps
,
*
str
,
*
rv
=
NULL
;
PyObject
*
samps
,
*
str
,
*
rv
=
NULL
,
*
channel
;
int
bytes_per_frame
;
if
(
!
audioop_check_size
(
width
))
...
...
@@ -1354,8 +1354,12 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
prev_i
[
chan
]
=
cur_i
[
chan
]
=
0
;
}
else
{
if
(
!
PyTuple_Check
(
state
))
{
PyErr_SetString
(
PyExc_TypeError
,
"state must be a tuple or None"
);
goto
exit
;
}
if
(
!
PyArg_ParseTuple
(
state
,
"iO!;
audioop.ratecv
: illegal state argument"
,
"iO!;
ratecv()
: illegal state argument"
,
&
d
,
&
PyTuple_Type
,
&
samps
))
goto
exit
;
if
(
PyTuple_Size
(
samps
)
!=
nchannels
)
{
...
...
@@ -1364,10 +1368,18 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
goto
exit
;
}
for
(
chan
=
0
;
chan
<
nchannels
;
chan
++
)
{
if
(
!
PyArg_ParseTuple
(
PyTuple_GetItem
(
samps
,
chan
),
"ii:ratecv"
,
&
prev_i
[
chan
],
&
cur_i
[
chan
]))
channel
=
PyTuple_GetItem
(
samps
,
chan
);
if
(
!
PyTuple_Check
(
channel
))
{
PyErr_SetString
(
PyExc_TypeError
,
"ratecv(): illegal state argument"
);
goto
exit
;
}
if
(
!
PyArg_ParseTuple
(
channel
,
"ii;ratecv(): illegal state argument"
,
&
prev_i
[
chan
],
&
cur_i
[
chan
]))
{
goto
exit
;
}
}
}
...
...
@@ -1638,7 +1650,9 @@ audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width,
PyErr_SetString
(
PyExc_TypeError
,
"state must be a tuple or None"
);
return
NULL
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
{
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii;lin2adpcm(): illegal state argument"
,
&
valpred
,
&
index
))
{
return
NULL
;
}
else
if
(
valpred
>=
0x8000
||
valpred
<
-
0x8000
||
...
...
@@ -1766,7 +1780,9 @@ audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width,
PyErr_SetString
(
PyExc_TypeError
,
"state must be a tuple or None"
);
return
NULL
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
{
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii;adpcm2lin(): illegal state argument"
,
&
valpred
,
&
index
))
{
return
NULL
;
}
else
if
(
valpred
>=
0x8000
||
valpred
<
-
0x8000
||
...
...
Modules/overlapped.c
View file @
1d1d3e9d
...
...
@@ -990,7 +990,9 @@ parse_address(PyObject *obj, SOCKADDR *Address, int Length)
((
SOCKADDR_IN
*
)
Address
)
->
sin_port
=
htons
(
Port
);
return
Length
;
}
else
if
(
PyArg_ParseTuple
(
obj
,
"uHkk"
,
&
Host
,
&
Port
,
&
FlowInfo
,
&
ScopeId
))
else
if
(
PyArg_ParseTuple
(
obj
,
"uHkk;ConnectEx(): illegal address_as_bytes "
"argument"
,
&
Host
,
&
Port
,
&
FlowInfo
,
&
ScopeId
))
{
PyErr_Clear
();
Address
->
sa_family
=
AF_INET6
;
...
...
@@ -1024,8 +1026,11 @@ Overlapped_ConnectEx(OverlappedObject *self, PyObject *args)
BOOL
ret
;
DWORD
err
;
if
(
!
PyArg_ParseTuple
(
args
,
F_HANDLE
"O"
,
&
ConnectSocket
,
&
AddressObj
))
if
(
!
PyArg_ParseTuple
(
args
,
F_HANDLE
"O!:ConnectEx"
,
&
ConnectSocket
,
&
PyTuple_Type
,
&
AddressObj
))
{
return
NULL
;
}
if
(
self
->
type
!=
TYPE_NONE
)
{
PyErr_SetString
(
PyExc_ValueError
,
"operation already attempted"
);
...
...
Modules/socketmodule.c
View file @
1d1d3e9d
...
...
@@ -5972,12 +5972,14 @@ socket_getnameinfo(PyObject *self, PyObject *args)
"getnameinfo() argument 1 must be a tuple"
);
return
NULL
;
}
if
(
!
PyArg_ParseTuple
(
sa
,
"si|II"
,
if
(
!
PyArg_ParseTuple
(
sa
,
"si|II
;getnameinfo(): illegal sockaddr argument
"
,
&
hostp
,
&
port
,
&
flowinfo
,
&
scope_id
))
{
return
NULL
;
}
if
(
flowinfo
>
0xfffff
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"get
sockaddrarg
: flowinfo must be 0-1048575."
);
"get
nameinfo()
: flowinfo must be 0-1048575."
);
return
NULL
;
}
PyOS_snprintf
(
pbuf
,
sizeof
(
pbuf
),
"%d"
,
port
);
...
...
Modules/timemodule.c
View file @
1d1d3e9d
...
...
@@ -415,7 +415,7 @@ When 'seconds' is not passed in, convert the current time instead.");
* an exception and return 0 on error.
*/
static
int
gettmarg
(
PyObject
*
args
,
struct
tm
*
p
)
gettmarg
(
PyObject
*
args
,
struct
tm
*
p
,
const
char
*
format
)
{
int
y
;
...
...
@@ -427,7 +427,7 @@ gettmarg(PyObject *args, struct tm *p)
return
0
;
}
if
(
!
PyArg_ParseTuple
(
args
,
"iiiiiiiii"
,
if
(
!
PyArg_ParseTuple
(
args
,
format
,
&
y
,
&
p
->
tm_mon
,
&
p
->
tm_mday
,
&
p
->
tm_hour
,
&
p
->
tm_min
,
&
p
->
tm_sec
,
&
p
->
tm_wday
,
&
p
->
tm_yday
,
&
p
->
tm_isdst
))
...
...
@@ -586,8 +586,12 @@ time_strftime(PyObject *self, PyObject *args)
if
(
_PyTime_localtime
(
tt
,
&
buf
)
!=
0
)
return
NULL
;
}
else
if
(
!
gettmarg
(
tup
,
&
buf
)
||
!
checktm
(
&
buf
))
else
if
(
!
gettmarg
(
tup
,
&
buf
,
"iiiiiiiii;strftime(): illegal time tuple argument"
)
||
!
checktm
(
&
buf
))
{
return
NULL
;
}
#if defined(_MSC_VER) || defined(sun) || defined(_AIX)
if
(
buf
.
tm_year
+
1900
<
1
||
9999
<
buf
.
tm_year
+
1900
)
{
...
...
@@ -776,9 +780,13 @@ time_asctime(PyObject *self, PyObject *args)
time_t
tt
=
time
(
NULL
);
if
(
_PyTime_localtime
(
tt
,
&
buf
)
!=
0
)
return
NULL
;
}
else
if
(
!
gettmarg
(
tup
,
&
buf
)
||
!
checktm
(
&
buf
))
}
else
if
(
!
gettmarg
(
tup
,
&
buf
,
"iiiiiiiii;asctime(): illegal time tuple argument"
)
||
!
checktm
(
&
buf
))
{
return
NULL
;
}
return
_asctime
(
&
buf
);
}
...
...
@@ -814,8 +822,11 @@ time_mktime(PyObject *self, PyObject *tup)
{
struct
tm
buf
;
time_t
tt
;
if
(
!
gettmarg
(
tup
,
&
buf
))
if
(
!
gettmarg
(
tup
,
&
buf
,
"iiiiiiiii;mktime(): illegal time tuple argument"
))
{
return
NULL
;
}
#ifdef _AIX
/* year < 1902 or year > 2037 */
if
(
buf
.
tm_year
<
2
||
buf
.
tm_year
>
137
)
{
...
...
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