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
af2b278b
Commit
af2b278b
authored
Nov 24, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19636: Fix posix__getvolumepathname(), raise an OverflowError if
the length doesn't fit in an DWORD
parent
09e24730
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
Modules/posixmodule.c
Modules/posixmodule.c
+14
-5
No files found.
Modules/posixmodule.c
View file @
af2b278b
...
...
@@ -385,6 +385,8 @@ static int win32_can_symlink = 0;
#endif
#endif
#define DWORD_MAX 4294967295U
#ifdef MS_WINDOWS
static
int
...
...
@@ -4039,24 +4041,31 @@ posix__getvolumepathname(PyObject *self, PyObject *args)
{
PyObject
*
po
,
*
result
;
wchar_t
*
path
,
*
mountpath
=
NULL
;
size_t
buf
size
;
size_t
buf
len
;
BOOL
ret
;
if
(
!
PyArg_ParseTuple
(
args
,
"U|:_getvolumepathname"
,
&
po
))
return
NULL
;
path
=
PyUnicode_AsUnicode
(
po
);
path
=
PyUnicode_AsUnicode
AndSize
(
po
,
&
buflen
);
if
(
path
==
NULL
)
return
NULL
;
buflen
+=
1
;
/* Volume path should be shorter than entire path */
bufsize
=
max
(
MAX_PATH
,
wcslen
(
path
)
*
2
*
sizeof
(
wchar_t
)
+
1
);
mountpath
=
(
wchar_t
*
)
PyMem_Malloc
(
bufsize
);
buflen
=
Py_MAX
(
buflen
,
MAX_PATH
);
if
(
buflen
>
DWORD_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"path too long"
);
return
NULL
;
}
mountpath
=
(
wchar_t
*
)
PyMem_Malloc
(
buflen
*
sizeof
(
wchar_t
));
if
(
mountpath
==
NULL
)
return
PyErr_NoMemory
();
Py_BEGIN_ALLOW_THREADS
ret
=
GetVolumePathNameW
(
path
,
mountpath
,
Py_SAFE_DOWNCAST
(
buf
size
,
size_t
,
DWORD
));
Py_SAFE_DOWNCAST
(
buf
len
,
size_t
,
DWORD
));
Py_END_ALLOW_THREADS
if
(
!
ret
)
{
...
...
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