]> The Tcpdump Group git mirrors - libpcap/commitdiff
Compute variable link header if we are computing the link payload.
authorJesse Gross <[email protected]>
Fri, 13 Feb 2015 00:33:36 +0000 (16:33 -0800)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 17 Feb 2015 14:40:00 +0000 (15:40 +0100)
The link payload is an absolute offset from the start of the packet,
meaning that it should include any variable link prefix as well.
However, currently if somebody asks for the payload but not the link
header, the latter is not computed and is skipped. This adds a
dependency between the two, so that we always calculate the full value.

gencode.c

index 6f03326c73aee59c0632986f780299dc36c312c7..ac03afeb139f067d16cfb9ff6165ff9459cfe344 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -2574,6 +2574,15 @@ insert_compute_vloffsets(b)
 {
        struct slist *s;
 
+       /* There is an implicit dependency between the link
+        * payload and link header since the payload computation
+        * includes the variable part of the header. Therefore,
+        * if nobody else has allocated a register for the link
+        * header and we need it, do it now. */
+       if (off_linkpl.reg != -1 && off_linkhdr.is_variable &&
+           off_linkhdr.reg == -1)
+               off_linkhdr.reg = alloc_reg();
+
        /*
         * For link-layer types that have a variable-length header
         * preceding the link-layer header, generate code to load