From ff9fdbd32f7e71a98c69017a3ebbe102dceb6c45 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 24 Dec 2011 12:06:41 -0200 Subject: [PATCH] Fix: handling packets with options length equal to zero. --- src/ip/ipv4header.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/ip/ipv4header.cpp b/src/ip/ipv4header.cpp index 7c13490..1c0dc22 100644 --- a/src/ip/ipv4header.cpp +++ b/src/ip/ipv4header.cpp @@ -232,7 +232,7 @@ istream &operator>>( GlobalLogger.error() << "Error: invalid IP options length value." << endl; is.setstate( ios::failbit ); } - else + else if ( ( 0 < options_length ) && ( options_length <= 40 ) ) { size_t options_size = static_cast( options_length ); scoped_array options_data( new uint8_t[options_size] ); @@ -242,6 +242,10 @@ istream &operator>>( header.Payload.append( options_data.get(), options_size ); } + else // ( options_length == 0 ) + { + //GlobalLogger.info() << "Info: No options available in this packet." << endl; + } return is; } -- 1.7.1