From 44fdd6ec4486e0224d11324383b7a99d89e550d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Tue, 26 Jan 2016 23:05:21 +0100 Subject: [PATCH] upd: check follow-up chunk-headers on re-assembling them --- src/io/record.cpp | 7 ++++++- src/io/record.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/io/record.cpp b/src/io/record.cpp index eed2e8f..c3a2270 100644 --- a/src/io/record.cpp +++ b/src/io/record.cpp @@ -112,6 +112,7 @@ std::string parseCommandChunked( RecordHeader& head, std::shared_ptrreadLine() ); + payload = parseCommand( head2, io->readLine() ); + if(!head2.isFollowupOf(head)){ + throw std::runtime_error("Error, header of follow up chunk was malformed"); + } + head = head2; } return all; } diff --git a/src/io/record.h b/src/io/record.h index d56708a..c06e6ad 100644 --- a/src/io/record.h +++ b/src/io/record.h @@ -102,7 +102,9 @@ public: read( it, offset ); read( it, payloadLength ); } - + bool isFollowupOf( const RecordHeader& head ) { + return head.command == command && head.flags == flags && head.sessid == sessid && head.command_count == command_count && head.totalLength == totalLength && head.offset + 1 == offset; + } }; std::string parseCommand( RecordHeader& head, const std::string& input ); -- 2.39.2