]> The Tcpdump Group git mirrors - libpcap/commitdiff
Include constant_part when loading IP header length.
authorJesse Gross <[email protected]>
Thu, 12 Feb 2015 19:02:05 +0000 (11:02 -0800)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 17 Feb 2015 14:40:00 +0000 (15:40 +0100)
When calculating the IP header length, we only use the variable
part of the link header to locate the IP header but we also need
to use any constant components.

Note that the constant part is not included in the total returned -
it is only used to actually locate the IP header. This is consistent
with other behavior.

gencode.c

index ac03afeb139f067d16cfb9ff6165ff9459cfe344..277015e39ff8cd578875137b70e5f6c86d2de9f9 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -1630,7 +1630,7 @@ gen_loadx_iphdrlen()
                 * the value from the X register.
                 */
                s2 = new_stmt(BPF_LD|BPF_IND|BPF_B);
-               s2->s.k = off_nl;
+               s2->s.k = off_linkpl.constant_part + off_nl;
                sappend(s, s2);
                s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
                s2->s.k = 0xf;