]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode: use pointer inside packet area as param
authorEric Leblond <eric@regit.org>
Wed, 5 Sep 2012 12:09:57 +0000 (14:09 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 6 Sep 2012 05:51:27 +0000 (07:51 +0200)
DecodeTeredo, DecodeIPv6InIPv6 and DecodeIPv4inIPv6 were calling
DecodeTunnel with packet being a pseudo packet and data being
data from initial packet:
        DecodeTunnel(tv, dtv, tp, start, blen,
                     pq, IPPROTO_IPV6);
In decoding functions, arithmetic was done on pkt to set some values?
It was resulting in field of packet  pointing outside of the scope of
packet data.
This patch switch to what has been done in DecodeGre(), I mean:
        DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp),
                     GET_PKT_LEN(tp), pq, IPPROTO_IP);
Data buffer is then relative to the packet and the arithmetic is
correct.

src/decode-ipv6.c
src/decode-teredo.c

index 95afe8ca19d5588d9c22b93c46838ecbb588fa68..03f5c99c5ef30caa8691a5e98946cf1160b25229 100644 (file)
@@ -60,7 +60,8 @@ static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, u
         if (pq != NULL) {
             Packet *tp = PacketPseudoPktSetup(p, pkt, plen, IPPROTO_IP);
             if (tp != NULL) {
-                DecodeTunnel(tv, dtv, tp, pkt, plen, pq, IPPROTO_IP);
+                DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp),
+                             GET_PKT_LEN(tp), pq, IPPROTO_IP);
                 PacketEnqueue(pq,tp);
                 SCPerfCounterIncr(dtv->counter_ipv4inipv6, tv->sc_perf_pca);
                 return;
@@ -87,7 +88,8 @@ static void DecodeIP6inIP6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uin
         if (pq != NULL) {
             Packet *tp = PacketPseudoPktSetup(p, pkt, plen, IPPROTO_IPV6);
             if (tp != NULL) {
-                DecodeTunnel(tv, dtv, tp, pkt, plen, pq, IPPROTO_IPV6);
+                DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp),
+                             GET_PKT_LEN(tp), pq, IPPROTO_IP);
                 PacketEnqueue(pq,tp);
                 SCPerfCounterIncr(dtv->counter_ipv6inipv6, tv->sc_perf_pca);
                 return;
index 193bbae923095fa4567e5e779ce860cc2e79e03d..844b365b76d1e586113e61c4e84f6f7f7b78a12b 100644 (file)
@@ -89,7 +89,7 @@ int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
                                                   IPPROTO_IPV6);
                 if (tp != NULL) {
                     /* send that to the Tunnel decoder */
-                    DecodeTunnel(tv, dtv, tp, start, blen,
+                    DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp),
                                  pq, IPPROTO_IPV6);
                     /* add the tp to the packet queue. */
                     PacketEnqueue(pq,tp);