]> WPIA git - cassiopeia.git/commitdiff
upd: check follow-up chunk-headers on re-assembling them
authorFelix Dörre <felix@dogcraft.de>
Tue, 26 Jan 2016 22:05:21 +0000 (23:05 +0100)
committerFelix Dörre <felix@dogcraft.de>
Tue, 26 Jan 2016 22:56:52 +0000 (23:56 +0100)
src/io/record.cpp
src/io/record.h

index eed2e8f37da9e58ffed738767f7e93a89e34263b..c3a2270c9174fbb775389ebabe4cd2b37d4e563d 100644 (file)
@@ -112,6 +112,7 @@ std::string parseCommandChunked( RecordHeader& head, std::shared_ptr<OpensslBIOW
     std::string all(head.totalLength, ' ');
     auto target = all.begin();
     size_t pos = 0;
+    RecordHeader head2;
     while(true) {
         pos += head.payloadLength;
         target = std::copy ( payload.begin(), payload.end(), target);
@@ -119,7 +120,11 @@ std::string parseCommandChunked( RecordHeader& head, std::shared_ptr<OpensslBIOW
             break;
         }
         logger::note("chunk digested, reading next one");
-        payload = parseCommand( head, io->readLine() );
+        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;
 }
index d56708aa9a768f84d453200f6c390e670c25c078..c06e6ad17114e1e5eb4e2862a950f80e8aef663e 100644 (file)
@@ -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 );