From: Josh Date: Tue, 4 Nov 2014 23:28:49 +0000 (-0600) Subject: more bug fixes. Invalid pointer arithmetic and adding another REG_TEST for frag... X-Git-Tag: 3.0.0-233~1265^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d34fbc27217ca3ca87ef548315ee473b6917b176;p=thirdparty%2Fsnort3.git more bug fixes. Invalid pointer arithmetic and adding another REG_TEST for frag options --- diff --git a/src/log/log_text.cc b/src/log/log_text.cc index 733512efc..f0d7e1315 100644 --- a/src/log/log_text.cc +++ b/src/log/log_text.cc @@ -690,6 +690,10 @@ void LogIPHeader(TextLog* log, Packet * p) /* print fragment info if necessary */ if(p->ptrs.decode_flags & DECODE_FRAG) { +#ifdef REG_TEST + frag_off = (frag_off >> 3); +#endif + TextLog_Print(log, "Frag Offset: 0x%04X Frag Size: 0x%04X\n", frag_off, p->ptrs.ip_api.pay_len()); } diff --git a/src/protocols/ip.cc b/src/protocols/ip.cc index 07e88aaf1..64bd371f5 100644 --- a/src/protocols/ip.cc +++ b/src/protocols/ip.cc @@ -127,7 +127,7 @@ uint16_t IpApi::off_w_flags() const const uint8_t* IpApi::ip_data() const { if (ip4h) - return reinterpret_cast(ip4h) + (ip4h->hlen()); + return reinterpret_cast(ip4h) + ip4h->hlen(); if (ip6h) return reinterpret_cast(ip6h) + ip6h->hlen(); diff --git a/src/protocols/ip.h b/src/protocols/ip.h index 9b63404d4..2246fe760 100644 --- a/src/protocols/ip.h +++ b/src/protocols/ip.h @@ -121,8 +121,9 @@ public: inline uint8_t proto() const { return ip4h ? ip4h->proto() : ip6h ? ip6h->next() : 0xFF; } - // NOTE: ipv4 len contains header, ipv6 header does not. If you - // want a standard, use dgram_len() or pay_len() instead. + // NOTE: ipv4 len contains header while an ipv6 header does not. If you + // want a length, use 'dgram_len() == length with header' or + // 'pay_len() == length without header' instead. // inline uint16_t len() const // { return ip4h ? ip4h->len() : ip6h ? ip6h->len() : 0; } @@ -142,7 +143,7 @@ public: // only relevent to IP4. inline const uint8_t* get_ip_opt_data() const - { return ip4h ? reinterpret_cast(ip4h + IP4_HEADER_LEN) : nullptr; } + { return ip4h ? reinterpret_cast(ip4h) + IP4_HEADER_LEN : nullptr; } inline const snort_in6_addr* get_ip6_src() const { return ip6h ? ip6h->get_src() : nullptr; }