summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2015-04-14 18:56:43 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2015-04-19 20:48:01 +0200
commit058c5307877c4e0d8cf8cbef1b83bbd187de1bc4 (patch)
tree65a786a532a7df5850a99a13723c59e3545e50b0
parent766d0dfd405fd1e0c6892d1bd3be9b599648f5d2 (diff)
downloadslixmpp-058c5307877c4e0d8cf8cbef1b83bbd187de1bc4.tar.gz
slixmpp-058c5307877c4e0d8cf8cbef1b83bbd187de1bc4.tar.bz2
slixmpp-058c5307877c4e0d8cf8cbef1b83bbd187de1bc4.tar.xz
slixmpp-058c5307877c4e0d8cf8cbef1b83bbd187de1bc4.zip
XEP-0047: prevent any unneededly large or useless bytes slice.
-rw-r--r--slixmpp/plugins/xep_0047/stream.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/slixmpp/plugins/xep_0047/stream.py b/slixmpp/plugins/xep_0047/stream.py
index 3b8c013d..eee6bd0e 100644
--- a/slixmpp/plugins/xep_0047/stream.py
+++ b/slixmpp/plugins/xep_0047/stream.py
@@ -34,7 +34,8 @@ class IBBytestream(object):
def send(self, data):
if not self.stream_started or self.stream_out_closed:
raise socket.error
- data = data[0:self.block_size]
+ if len(data) > self.block_size:
+ data = data[:self.block_size]
self.send_seq = (self.send_seq + 1) % 65535
seq = self.send_seq
if self.use_messages:
@@ -60,7 +61,7 @@ class IBBytestream(object):
def sendall(self, data):
sent_len = 0
while sent_len < len(data):
- sent_len += self.send(data[sent_len:])
+ sent_len += self.send(data[sent_len:self.block_size])
def _recv_ack(self, iq):
if iq['type'] == 'error':