From b3b38015c28a3b7e052023f116c0ca99c170ab9c Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 20 Jan 2018 07:31:05 -0500 Subject: [PATCH] check max buffer size in Stream::Send --- libi2pd/Streaming.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 37d9d2c4..9942d8e2 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -378,9 +378,15 @@ namespace stream size_t Stream::Send (const uint8_t * buf, size_t len) { - // TODO: check max buffer size + size_t sent = len; + while(len > MAX_PACKET_SIZE) + { + AsyncSend (buf, MAX_PACKET_SIZE, nullptr); + buf += MAX_PACKET_SIZE; + len -= MAX_PACKET_SIZE; + } AsyncSend (buf, len, nullptr); - return len; + return sent; } void Stream::AsyncSend (const uint8_t * buf, size_t len, SendHandler handler)