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
ef4bb1e9
Commit
ef4bb1e9
authored
Mar 28, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #23804: Merge SSL zero read fix from 3.5
parents
2a65ecb7
f6b1d66a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
5 deletions
+15
-5
Doc/library/ssl.rst
Doc/library/ssl.rst
+1
-1
Lib/ssl.py
Lib/ssl.py
+3
-3
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+8
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/ssl.rst
View file @
ef4bb1e9
...
@@ -842,7 +842,7 @@ SSL Sockets
...
@@ -842,7 +842,7 @@ SSL Sockets
SSL sockets also have the following additional methods and attributes:
SSL sockets also have the following additional methods and attributes:
.. method:: SSLSocket.read(len=
0
, buffer=None)
.. method:: SSLSocket.read(len=
1024
, buffer=None)
Read up to *len* bytes of data from the SSL socket and return the result as
Read up to *len* bytes of data from the SSL socket and return the result as
a ``bytes`` instance. If *buffer* is specified, then read into the buffer
a ``bytes`` instance. If *buffer* is specified, then read into the buffer
...
...
Lib/ssl.py
View file @
ef4bb1e9
...
@@ -561,7 +561,7 @@ class SSLObject:
...
@@ -561,7 +561,7 @@ class SSLObject:
server hostame is set."""
server hostame is set."""
return
self
.
_sslobj
.
server_hostname
return
self
.
_sslobj
.
server_hostname
def
read
(
self
,
len
=
0
,
buffer
=
None
):
def
read
(
self
,
len
=
1024
,
buffer
=
None
):
"""Read up to 'len' bytes from the SSL object and return them.
"""Read up to 'len' bytes from the SSL object and return them.
If 'buffer' is provided, read into this buffer and return the number of
If 'buffer' is provided, read into this buffer and return the number of
...
@@ -570,7 +570,7 @@ class SSLObject:
...
@@ -570,7 +570,7 @@ class SSLObject:
if
buffer
is
not
None
:
if
buffer
is
not
None
:
v
=
self
.
_sslobj
.
read
(
len
,
buffer
)
v
=
self
.
_sslobj
.
read
(
len
,
buffer
)
else
:
else
:
v
=
self
.
_sslobj
.
read
(
len
or
1024
)
v
=
self
.
_sslobj
.
read
(
len
)
return
v
return
v
def
write
(
self
,
data
):
def
write
(
self
,
data
):
...
@@ -776,7 +776,7 @@ class SSLSocket(socket):
...
@@ -776,7 +776,7 @@ class SSLSocket(socket):
# EAGAIN.
# EAGAIN.
self
.
getpeername
()
self
.
getpeername
()
def
read
(
self
,
len
=
0
,
buffer
=
None
):
def
read
(
self
,
len
=
1024
,
buffer
=
None
):
"""Read up to LEN bytes and return them.
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
Return zero-length string on EOF."""
...
...
Lib/test/test_ssl.py
View file @
ef4bb1e9
...
@@ -2783,13 +2783,20 @@ if _have_threads:
...
@@ -2783,13 +2783,20 @@ if _have_threads:
# consume data
# consume data
s
.
read
()
s
.
read
()
# read(-1, buffer) is supported, even though read(-1) is not
data
=
b"data"
data
=
b"data"
# read(-1, buffer) is supported, even though read(-1) is not
s
.
send
(
data
)
s
.
send
(
data
)
buffer
=
bytearray
(
len
(
data
))
buffer
=
bytearray
(
len
(
data
))
self
.
assertEqual
(
s
.
read
(
-
1
,
buffer
),
len
(
data
))
self
.
assertEqual
(
s
.
read
(
-
1
,
buffer
),
len
(
data
))
self
.
assertEqual
(
buffer
,
data
)
self
.
assertEqual
(
buffer
,
data
)
# recv/read(0) should return no data
s
.
send
(
data
)
self
.
assertEqual
(
s
.
recv
(
0
),
b""
)
self
.
assertEqual
(
s
.
read
(
0
),
b""
)
self
.
assertEqual
(
s
.
read
(),
data
)
# Make sure sendmsg et al are disallowed to avoid
# Make sure sendmsg et al are disallowed to avoid
# inadvertent disclosure of data and/or corruption
# inadvertent disclosure of data and/or corruption
# of the encrypted data stream
# of the encrypted data stream
...
...
Misc/NEWS
View file @
ef4bb1e9
...
@@ -239,6 +239,9 @@ Library
...
@@ -239,6 +239,9 @@ Library
-
Issue
#
26644
:
Raise
ValueError
rather
than
SystemError
when
a
negative
-
Issue
#
26644
:
Raise
ValueError
rather
than
SystemError
when
a
negative
length
is
passed
to
SSLSocket
.
recv
()
or
read
().
length
is
passed
to
SSLSocket
.
recv
()
or
read
().
-
Issue
#
23804
:
Fix
SSL
recv
(
0
)
and
read
(
0
)
methods
to
return
zero
bytes
instead
of
up
to
1024.
-
Issue
#
26616
:
Fixed
a
bug
in
datetime
.
astimezone
()
method
.
-
Issue
#
26616
:
Fixed
a
bug
in
datetime
.
astimezone
()
method
.
-
Issue
#
26637
:
The
:
mod
:`
importlib
`
module
now
emits
an
:
exc
:`
ImportError
`
-
Issue
#
26637
:
The
:
mod
:`
importlib
`
module
now
emits
an
:
exc
:`
ImportError
`
...
...
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