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
59729ff6
Commit
59729ff6
authored
Jul 05, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9611, #9015: FileIO.read(), FileIO.readinto(), FileIO.write() and
os.write() clamp the length to INT_MAX on Windows.
parent
4833c98f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-7
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_io/fileio.c
Modules/_io/fileio.c
+26
-4
Modules/posixmodule.c
Modules/posixmodule.c
+10
-3
No files found.
Misc/NEWS
View file @
59729ff6
...
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.3?
Core and Builtins
-----------------
- Issue #9611, #9015: FileIO.read(), FileIO.readinto(), FileIO.write() and
os.write() clamp the length to INT_MAX on Windows.
- Issue #1195: my_fgets() now always clears errors before calling fgets(). Fix
the following case: sys.stdin.read() stopped with CTRL+d (end of file),
raw_input() interrupted by CTRL+c.
...
...
Modules/_io/fileio.c
View file @
59729ff6
...
...
@@ -474,7 +474,7 @@ static PyObject *
fileio_readinto
(
fileio
*
self
,
PyObject
*
args
)
{
Py_buffer
pbuf
;
Py_ssize_t
n
;
Py_ssize_t
n
,
len
;
if
(
self
->
fd
<
0
)
return
err_closed
();
...
...
@@ -485,9 +485,16 @@ fileio_readinto(fileio *self, PyObject *args)
return
NULL
;
if
(
_PyVerify_fd
(
self
->
fd
))
{
len
=
pbuf
.
len
;
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
n
=
read
(
self
->
fd
,
pbuf
.
buf
,
pbuf
.
len
);
#if defined(MS_WIN64) || defined(MS_WINDOWS)
if
(
len
>
INT_MAX
)
len
=
INT_MAX
;
n
=
read
(
self
->
fd
,
pbuf
.
buf
,
(
int
)
len
);
#else
n
=
read
(
self
->
fd
,
pbuf
.
buf
,
len
);
#endif
Py_END_ALLOW_THREADS
}
else
n
=
-
1
;
...
...
@@ -620,6 +627,10 @@ fileio_read(fileio *self, PyObject *args)
return
fileio_readall
(
self
);
}
#if defined(MS_WIN64) || defined(MS_WINDOWS)
if
(
size
>
INT_MAX
)
size
=
INT_MAX
;
#endif
bytes
=
PyBytes_FromStringAndSize
(
NULL
,
size
);
if
(
bytes
==
NULL
)
return
NULL
;
...
...
@@ -628,7 +639,11 @@ fileio_read(fileio *self, PyObject *args)
if
(
_PyVerify_fd
(
self
->
fd
))
{
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
#if defined(MS_WIN64) || defined(MS_WINDOWS)
n
=
read
(
self
->
fd
,
ptr
,
(
int
)
size
);
#else
n
=
read
(
self
->
fd
,
ptr
,
size
);
#endif
Py_END_ALLOW_THREADS
}
else
n
=
-
1
;
...
...
@@ -655,7 +670,7 @@ static PyObject *
fileio_write
(
fileio
*
self
,
PyObject
*
args
)
{
Py_buffer
pbuf
;
Py_ssize_t
n
;
Py_ssize_t
n
,
len
;
if
(
self
->
fd
<
0
)
return
err_closed
();
...
...
@@ -668,7 +683,14 @@ fileio_write(fileio *self, PyObject *args)
if
(
_PyVerify_fd
(
self
->
fd
))
{
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
n
=
write
(
self
->
fd
,
pbuf
.
buf
,
pbuf
.
len
);
len
=
pbuf
.
len
;
#if defined(MS_WIN64) || defined(MS_WINDOWS)
if
(
len
>
INT_MAX
)
len
=
INT_MAX
;
n
=
write
(
self
->
fd
,
pbuf
.
buf
,
(
int
)
len
);
#else
n
=
write
(
self
->
fd
,
pbuf
.
buf
,
len
);
#endif
Py_END_ALLOW_THREADS
}
else
n
=
-
1
;
...
...
Modules/posixmodule.c
View file @
59729ff6
...
...
@@ -3903,7 +3903,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
#endif
gid_t
grouplist
[
MAX_GROUPS
];
/* On MacOSX getgroups(2) can return more than MAX_GROUPS results
/* On MacOSX getgroups(2) can return more than MAX_GROUPS results
* This is a helper variable to store the intermediate result when
* that happens.
*
...
...
@@ -6648,7 +6648,7 @@ posix_write(PyObject *self, PyObject *args)
{
Py_buffer
pbuf
;
int
fd
;
Py_ssize_t
size
;
Py_ssize_t
size
,
len
;
if
(
!
PyArg_ParseTuple
(
args
,
"is*:write"
,
&
fd
,
&
pbuf
))
return
NULL
;
...
...
@@ -6656,8 +6656,15 @@ posix_write(PyObject *self, PyObject *args)
PyBuffer_Release
(
&
pbuf
);
return
posix_error
();
}
len
=
pbuf
.
len
;
Py_BEGIN_ALLOW_THREADS
size
=
write
(
fd
,
pbuf
.
buf
,
(
size_t
)
pbuf
.
len
);
#if defined(MS_WIN64) || defined(MS_WINDOWS)
if
(
len
>
INT_MAX
)
len
=
INT_MAX
;
size
=
write
(
fd
,
pbuf
.
buf
,
(
int
)
len
);
#else
size
=
write
(
fd
,
pbuf
.
buf
,
len
);
#endif
Py_END_ALLOW_THREADS
PyBuffer_Release
(
&
pbuf
);
if
(
size
<
0
)
...
...
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