소스 검색

Check payload size in append channel

Jonas Pflanzer 4 년 전
부모
커밋
4935998458
1개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 10 5
      daemon/include/CovertChannel/Channels/TCPAppendChannel.hpp

+ 10 - 5
daemon/include/CovertChannel/Channels/TCPAppendChannel.hpp

@@ -53,13 +53,18 @@ protected:
 
 			// read data from payload
 			std::size_t size = payload.size();
-			uint8_t *data = &payload.front();
-			data += size - N;
 
-			BidirectionalChannels<N, PASSIVE>::protocol.receive(data);
+			if (size < N) {
+				std::cerr << __PRETTY_FUNCTION__ << " payload size is too small" << std::endl;
+			} else {
+				uint8_t *data = &payload.front();
+				data += size - N;
 
-			// resize payload
-			payload.resize(size - N);
+				BidirectionalChannels<N, PASSIVE>::protocol.receive(data);
+
+				// resize payload
+				payload.resize(size - N);
+			}
 		}
 
 		BidirectionalChannels<N, PASSIVE>::innerSender.send(pdu);