]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
more bug fixes. Invalid pointer arithmetic and adding another REG_TEST for frag...
authorJosh <jrosenba@cisco.com>
Tue, 4 Nov 2014 23:28:49 +0000 (17:28 -0600)
committerJosh <jrosenba@cisco.com>
Tue, 4 Nov 2014 23:28:49 +0000 (17:28 -0600)
src/log/log_text.cc
src/protocols/ip.cc
src/protocols/ip.h

index 733512efc4c72cbe471b4717e562df358d8fe0a8..f0d7e1315bb43dbab1dfc941eae0dc03a8349f9a 100644 (file)
@@ -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());
     }
index 07e88aaf166618c03ce49b8558f1a3ea91d4a2e7..64bd371f57ff845b7c95fbb5f46ee6a00f3f8909 100644 (file)
@@ -127,7 +127,7 @@ uint16_t IpApi::off_w_flags() const
 const uint8_t* IpApi::ip_data() const
 {
     if (ip4h)
-        return reinterpret_cast<const uint8_t*>(ip4h) + (ip4h->hlen());
+        return reinterpret_cast<const uint8_t*>(ip4h) + ip4h->hlen();
 
     if (ip6h)
         return reinterpret_cast<const uint8_t*>(ip6h) + ip6h->hlen();
index 9b63404d4b499c88b2a66e48e22191f3d9975605..2246fe760cdf06c1212d3031f732513ac7b4581f 100644 (file)
@@ -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<const uint8_t*>(ip4h + IP4_HEADER_LEN) : nullptr; }
+    { return ip4h ? reinterpret_cast<const uint8_t*>(ip4h) + IP4_HEADER_LEN : nullptr; }
 
     inline const snort_in6_addr* get_ip6_src() const
     { return ip6h ? ip6h->get_src() : nullptr; }