diff options
author | Dana Powers <dana.powers@gmail.com> | 2016-07-17 12:08:57 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2016-07-17 12:08:57 -0700 |
commit | d179a3f62e7d225b087290b51f3bc387aa9d434b (patch) | |
tree | cb1131395122b2daabe7775126795b7268856f27 | |
parent | 77360a167fc5fab1c3204be2524a1f21d8dbef51 (diff) | |
download | kafka-python-d179a3f62e7d225b087290b51f3bc387aa9d434b.tar.gz |
Avoid buffer overread when compressing messageset in KafkaProducer
-rw-r--r-- | kafka/producer/buffer.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kafka/producer/buffer.py b/kafka/producer/buffer.py index 0c49828..5f41bac 100644 --- a/kafka/producer/buffer.py +++ b/kafka/producer/buffer.py @@ -103,8 +103,9 @@ class MessageSetBuffer(object): if not self._closed: if self._compressor: # TODO: avoid copies with bytearray / memoryview + uncompressed_size = self._buffer.tell() self._buffer.seek(4) - msg = Message(self._compressor(self._buffer.read()), + msg = Message(self._compressor(self._buffer.read(uncompressed_size - 4)), attributes=self._compression_attributes, magic=self._message_version) encoded = msg.encode() |