]> The Tcpdump Group git mirrors - tcpdump/commit
Loopback/CTP: Modernize packet parsing style.
authorDenis Ovsienko <[email protected]>
Fri, 18 Sep 2020 01:27:43 +0000 (02:27 +0100)
committerDenis Ovsienko <[email protected]>
Fri, 18 Sep 2020 21:24:09 +0000 (22:24 +0100)
commit5c6c98f2c58103f20f5cbc933bdf0a1406366b43
tree26428659bcd6cf30287dd8c727dd89fee691912b
parent11abdc627d933f938637bcd987d7362abb9dc57e
Loopback/CTP: Modernize packet parsing style.

The change made in commit bdd97f54 was safe, but was slightly incorrect.

Before the change the decoder used the _declared_ end of packet (the
initial "cp" + the initial "len") as the target of how much data to try
to decode, and whilst trying to do that it could cross the _captured_ end
of packet (ndo_snapend) and give up complaining, so the output would
correctly indicate there was supposed to be more data beyond the
unexpected snapshot end.

After the change the decoder started to use the captured end of packet to
tell where the packet ends, so it would never cross ndo_snapend, but it
would interpret the packet data as if the missing part was never supposed
to be there and would thus decode truncated packets incorrectly.

In order to eliminate this space for misinterpretation, remove the "ep"
pointer and change the code both to advance "cp" and to decrease "len" as
it is going through the protocol structures, so the part of the packet
that is supposed to be present but has not been decoded yet can be
addressed by just "cp" and "len" (like it is done in many functions
elsewhere). Let the GET_ macros guard the snapshot end and use nd_trunc()
to handle the remaining ND_TCHECK_LEN() instances.

Articulate the part of the message sized by skipCount.
print-loopback.c