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
5bc6a7c0
Commit
5bc6a7c0
authored
Oct 21, 2019
by
Serhiy Storchaka
Committed by
GitHub
Oct 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38540: Fix possible leak in PyArg_Parse for "es#" and "et#". (GH-16869)
parent
2eba6ad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
Misc/NEWS.d/next/C API/2019-10-21-09-24-03.bpo-38540.314N_T.rst
...EWS.d/next/C API/2019-10-21-09-24-03.bpo-38540.314N_T.rst
+3
-0
Python/getargs.c
Python/getargs.c
+26
-2
No files found.
Misc/NEWS.d/next/C API/2019-10-21-09-24-03.bpo-38540.314N_T.rst
0 → 100644
View file @
5bc6a7c0
Fixed possible leak in :c:func:`PyArg_Parse` and similar functions for
format units ``"es#"`` and ``"et#"`` when the macro
:c:macro:`PY_SSIZE_T_CLEAN` is not defined.
Python/getargs.c
View file @
5bc6a7c0
...
...
@@ -1199,7 +1199,19 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
trailing 0-byte
*/
FETCH_SIZE
;
int
*
q
=
NULL
;
Py_ssize_t
*
q2
=
NULL
;
if
(
flags
&
FLAG_SIZE_T
)
{
q2
=
va_arg
(
*
p_va
,
Py_ssize_t
*
);
}
else
{
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
"PY_SSIZE_T_CLEAN will be required for '#' formats"
,
1
))
{
Py_DECREF
(
s
);
return
NULL
;
}
q
=
va_arg
(
*
p_va
,
int
*
);
}
format
++
;
if
(
q
==
NULL
&&
q2
==
NULL
)
{
...
...
@@ -1232,7 +1244,19 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
}
}
memcpy
(
*
buffer
,
ptr
,
size
+
1
);
STORE_SIZE
(
size
);
if
(
flags
&
FLAG_SIZE_T
)
{
*
q2
=
size
;
}
else
{
if
(
INT_MAX
<
size
)
{
Py_DECREF
(
s
);
PyErr_SetString
(
PyExc_OverflowError
,
"size does not fit in an int"
);
return
converterr
(
""
,
arg
,
msgbuf
,
bufsize
);
}
*
q
=
(
int
)
size
;
}
}
else
{
/* Using a 0-terminated buffer:
...
...
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