Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

Commit

Permalink
SSLSocket write and send methods check for empty input
Browse files Browse the repository at this point in the history
Closes gevent#719
  • Loading branch information
tt-savola committed Feb 18, 2016
1 parent ca60c7a commit 1656884
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gevent/_ssl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def read(self, len=1024):
def write(self, data):
"""Write DATA to the underlying SSL channel. Returns
number of bytes of DATA actually transmitted."""
if len(data) == 0:
return 0
while True:
try:
return self._sslobj.write(data)
Expand Down Expand Up @@ -173,6 +175,8 @@ def send(self, data, flags=0, timeout=timeout_default):
raise ValueError(
"non-zero flags not allowed in calls to send() on %s" %
self.__class__)
if len(data) == 0:
return 0
while True:
try:
v = self._sslobj.write(data)
Expand Down
4 changes: 4 additions & 0 deletions gevent/_ssl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ def write(self, data):
if not self._sslobj:
raise ValueError("Write on closed or unwrapped SSL socket.")

if len(data) == 0:
return 0
while True:
try:
return self._sslobj.write(data)
Expand Down Expand Up @@ -332,6 +334,8 @@ def send(self, data, flags=0, timeout=timeout_default):
raise ValueError(
"non-zero flags not allowed in calls to send() on %s" %
self.__class__)
if len(data) == 0:
return 0
while True:
try:
return self._sslobj.write(data)
Expand Down
4 changes: 4 additions & 0 deletions gevent/_sslgte279.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ def write(self, data):
self._checkClosed()
if not self._sslobj:
raise ValueError("Write on closed or unwrapped SSL socket.")
if len(data) == 0:
return 0
while True:
try:
return self._sslobj.write(data)
Expand Down Expand Up @@ -398,6 +400,8 @@ def send(self, data, flags=0, timeout=timeout_default):
if not self._sslobj:
return socket.send(self, data, flags, timeout)

if len(data) == 0:
return 0
while True:
try:
return self._sslobj.write(data)
Expand Down

0 comments on commit 1656884

Please sign in to comment.