Skip to content

Commit

Permalink
Merge 61ce081 into d82944f
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Sep 16, 2019
2 parents d82944f + 61ce081 commit 154e34b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions tlslite/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,7 @@ def parse(self, p):
"""
self.message_type = p.get(1)
self.payload = p.getVarBytes(2)
self.padding = p.getFixBytes(p.getRemainingLength())
return self

def write(self):
Expand Down
14 changes: 9 additions & 5 deletions tlslite/tlsrecordlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,20 +845,24 @@ def _getMsg(self, expectedType, secondaryType=None, constructorType=None):
"Received heartbeat_request to "
"peer_not_allowed_to_send mode"):
yield result
else:
heartbeat_response = heartbeat_message.\
create_response()
if len(heartbeat_message.padding) < 16:
# per RFC, silently ignore if the message
# is malformed
continue
heartbeat_response = heartbeat_message.\
create_response()
for result in self._sendMsg(
heartbeat_response):
yield result
# If we received heartbeat response, then we
# check, if its payload is same as payload of
# request we sent
elif heartbeat_message.message_type == \
HeartbeatMessageType.heartbeat_response:
HeartbeatMessageType.heartbeat_response \
and self.heartbeat_response_callback:
self.heartbeat_response_callback(
heartbeat_message)
except socket.error:
except (socket.error, SyntaxError):
pass
continue

Expand Down

0 comments on commit 154e34b

Please sign in to comment.