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
bf0fc39e
Commit
bf0fc39e
authored
Feb 04, 2017
by
Steve Dower
Browse files
Options
Browse Files
Download
Plain Diff
Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
parents
1add96f1
21fae03e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
Misc/NEWS
Misc/NEWS
+2
-0
PC/msvcrtmodule.c
PC/msvcrtmodule.c
+43
-4
No files found.
Misc/NEWS
View file @
bf0fc39e
...
@@ -146,6 +146,8 @@ Library
...
@@ -146,6 +146,8 @@ Library
Windows
Windows
-------
-------
- Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
- Issue #25778: winreg does not truncate string correctly (Patch by Eryk Sun)
- Issue #25778: winreg does not truncate string correctly (Patch by Eryk Sun)
- Issue #28896: Deprecate WindowsRegistryFinder and disable it by default.
- Issue #28896: Deprecate WindowsRegistryFinder and disable it by default.
...
...
PC/msvcrtmodule.c
View file @
bf0fc39e
...
@@ -111,7 +111,9 @@ msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes)
...
@@ -111,7 +111,9 @@ msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes)
int
err
;
int
err
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
err
=
_locking
(
fd
,
mode
,
nbytes
);
err
=
_locking
(
fd
,
mode
,
nbytes
);
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
err
!=
0
)
if
(
err
!=
0
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -138,7 +140,9 @@ static long
...
@@ -138,7 +140,9 @@ static long
msvcrt_setmode_impl
(
PyObject
*
module
,
int
fd
,
int
flags
)
msvcrt_setmode_impl
(
PyObject
*
module
,
int
fd
,
int
flags
)
/*[clinic end generated code: output=24a9be5ea07ccb9b input=76e7c01f6b137f75]*/
/*[clinic end generated code: output=24a9be5ea07ccb9b input=76e7c01f6b137f75]*/
{
{
_Py_BEGIN_SUPPRESS_IPH
flags
=
_setmode
(
fd
,
flags
);
flags
=
_setmode
(
fd
,
flags
);
_Py_END_SUPPRESS_IPH
if
(
flags
==
-
1
)
if
(
flags
==
-
1
)
PyErr_SetFromErrno
(
PyExc_IOError
);
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -165,7 +169,9 @@ msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags)
...
@@ -165,7 +169,9 @@ msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags)
{
{
int
fd
;
int
fd
;
_Py_BEGIN_SUPPRESS_IPH
fd
=
_open_osfhandle
(
handle
,
flags
);
fd
=
_open_osfhandle
(
handle
,
flags
);
_Py_END_SUPPRESS_IPH
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
PyErr_SetFromErrno
(
PyExc_IOError
);
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -303,7 +309,9 @@ static PyObject *
...
@@ -303,7 +309,9 @@ static PyObject *
msvcrt_putch_impl
(
PyObject
*
module
,
char
char_value
)
msvcrt_putch_impl
(
PyObject
*
module
,
char
char_value
)
/*[clinic end generated code: output=92ec9b81012d8f60 input=ec078dd10cb054d6]*/
/*[clinic end generated code: output=92ec9b81012d8f60 input=ec078dd10cb054d6]*/
{
{
_Py_BEGIN_SUPPRESS_IPH
_putch
(
char_value
);
_putch
(
char_value
);
_Py_END_SUPPRESS_IPH
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
...
@@ -320,7 +328,9 @@ static PyObject *
...
@@ -320,7 +328,9 @@ static PyObject *
msvcrt_putwch_impl
(
PyObject
*
module
,
int
unicode_char
)
msvcrt_putwch_impl
(
PyObject
*
module
,
int
unicode_char
)
/*[clinic end generated code: output=a3bd1a8951d28eee input=996ccd0bbcbac4c3]*/
/*[clinic end generated code: output=a3bd1a8951d28eee input=996ccd0bbcbac4c3]*/
{
{
_Py_BEGIN_SUPPRESS_IPH
_putwch
(
unicode_char
);
_putwch
(
unicode_char
);
_Py_END_SUPPRESS_IPH
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
...
@@ -342,7 +352,13 @@ static PyObject *
...
@@ -342,7 +352,13 @@ static PyObject *
msvcrt_ungetch_impl
(
PyObject
*
module
,
char
char_value
)
msvcrt_ungetch_impl
(
PyObject
*
module
,
char
char_value
)
/*[clinic end generated code: output=c6942a0efa119000 input=22f07ee9001bbf0f]*/
/*[clinic end generated code: output=c6942a0efa119000 input=22f07ee9001bbf0f]*/
{
{
if
(
_ungetch
(
char_value
)
==
EOF
)
int
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
_ungetch
(
char_value
);
_Py_END_SUPPRESS_IPH
if
(
res
==
EOF
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
...
@@ -360,7 +376,13 @@ static PyObject *
...
@@ -360,7 +376,13 @@ static PyObject *
msvcrt_ungetwch_impl
(
PyObject
*
module
,
int
unicode_char
)
msvcrt_ungetwch_impl
(
PyObject
*
module
,
int
unicode_char
)
/*[clinic end generated code: output=e63af05438b8ba3d input=83ec0492be04d564]*/
/*[clinic end generated code: output=e63af05438b8ba3d input=83ec0492be04d564]*/
{
{
if
(
_ungetwch
(
unicode_char
)
==
WEOF
)
int
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
_ungetwch
(
unicode_char
);
_Py_END_SUPPRESS_IPH
if
(
res
==
WEOF
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
...
@@ -382,7 +404,13 @@ static long
...
@@ -382,7 +404,13 @@ static long
msvcrt_CrtSetReportFile_impl
(
PyObject
*
module
,
int
type
,
int
file
)
msvcrt_CrtSetReportFile_impl
(
PyObject
*
module
,
int
type
,
int
file
)
/*[clinic end generated code: output=df291c7fe032eb68 input=bb8f721a604fcc45]*/
/*[clinic end generated code: output=df291c7fe032eb68 input=bb8f721a604fcc45]*/
{
{
return
(
long
)
_CrtSetReportFile
(
type
,
(
_HFILE
)
file
);
long
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
(
long
)
_CrtSetReportFile
(
type
,
(
_HFILE
)
file
);
_Py_END_SUPPRESS_IPH
return
res
;
}
}
/*[clinic input]
/*[clinic input]
...
@@ -403,7 +431,9 @@ msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode)
...
@@ -403,7 +431,9 @@ msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode)
{
{
int
res
;
int
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
_CrtSetReportMode
(
type
,
mode
);
res
=
_CrtSetReportMode
(
type
,
mode
);
_Py_END_SUPPRESS_IPH
if
(
res
==
-
1
)
if
(
res
==
-
1
)
PyErr_SetFromErrno
(
PyExc_IOError
);
PyErr_SetFromErrno
(
PyExc_IOError
);
return
res
;
return
res
;
...
@@ -424,7 +454,13 @@ static long
...
@@ -424,7 +454,13 @@ static long
msvcrt_set_error_mode_impl
(
PyObject
*
module
,
int
mode
)
msvcrt_set_error_mode_impl
(
PyObject
*
module
,
int
mode
)
/*[clinic end generated code: output=ac4a09040d8ac4e3 input=046fca59c0f20872]*/
/*[clinic end generated code: output=ac4a09040d8ac4e3 input=046fca59c0f20872]*/
{
{
return
_set_error_mode
(
mode
);
long
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
_set_error_mode
(
mode
);
_Py_END_SUPPRESS_IPH
return
res
;
}
}
#endif
/* _DEBUG */
#endif
/* _DEBUG */
...
@@ -443,7 +479,10 @@ msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode)
...
@@ -443,7 +479,10 @@ msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode)
{
{
unsigned
int
res
;
unsigned
int
res
;
_Py_BEGIN_SUPPRESS_IPH
res
=
SetErrorMode
(
mode
);
res
=
SetErrorMode
(
mode
);
_Py_END_SUPPRESS_IPH
return
PyLong_FromUnsignedLong
(
res
);
return
PyLong_FromUnsignedLong
(
res
);
}
}
...
...
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