From eb8ded5f50e24490b78df0e947333ab25301f522 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 18 Mar 2015 11:45:07 +0100 Subject: [PATCH] in case of unknown ICMP reply type, consume data instead of returning failure in IcmpPacket::read --- src/icmp/icmpdata.h | 5 ++--- src/icmp/icmppacket.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/icmp/icmpdata.h b/src/icmp/icmpdata.h index 7e92f64..f53f160 100644 --- a/src/icmp/icmpdata.h +++ b/src/icmp/icmpdata.h @@ -42,6 +42,8 @@ class IcmpData public: IcmpData(); + IcmpData(const std::size_t size_arg); + virtual ~IcmpData() {}; virtual bool match_echo_reply(const uint16_t identifier, @@ -75,9 +77,6 @@ public: protected: - // called by subclasses - IcmpData(const std::size_t size_arg); - std::size_t size; MessagePayload raw_data; }; diff --git a/src/icmp/icmppacket.cpp b/src/icmp/icmppacket.cpp index 95bb8a4..b90f481 100644 --- a/src/icmp/icmppacket.cpp +++ b/src/icmp/icmppacket.cpp @@ -213,7 +213,12 @@ IcmpPacket::ReadReturnCode IcmpPacket::read( std::istream &is ) icmp_data_ptr.reset( new IcmpDestinationUnreachableData( static_cast(data_length)) ); else - return ReadReturnCode_UNKNOWN_ICMP_TYPE; + { // unspecified icmp data type, will consume right amount of data + // from stream but return false for match_echo_request and + // match_destination_unreachable + icmp_data_ptr.reset( new IcmpData( + static_cast(data_length)) ); + } icmp_data_ptr->read( is ); } -- 1.7.1