From: Denis Ovsienko Date: Fri, 10 May 2013 12:03:08 +0000 (+0400) Subject: fix iteration over Babel Pad1 TLVs X-Git-Tag: tcpdump-4.5.0~73^2~15 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/d0b48b5108a77959ac65c499d1ab577c000c5804 fix iteration over Babel Pad1 TLVs The Pad1 TLV consists only of the Type field (RFC6126 Section 4.4.1), thus the check for Pad1 type must be done before the Length field is consumed, if ever. This change brings tcpdump decoder into line with the spec and Babel implementation's own TLV iterator. --- diff --git a/print-babel.c b/print-babel.c index c15f9586..8b422b3f 100644 --- a/print-babel.c +++ b/print-babel.c @@ -212,23 +212,22 @@ babel_print_v2(const u_char *cp, u_int length) { u_int type, len; message = cp + 4 + i; + + TCHECK2(*message, 1); + if((type = message[0]) == MESSAGE_PAD1) { + printf(vflag ? "\n\tPad 1" : " pad1"); + i += 1; + continue; + } + TCHECK2(*message, 2); ICHECK(i, 2); - type = message[0]; len = message[1]; TCHECK2(*message, 2 + len); ICHECK(i, 2 + len); switch(type) { - case MESSAGE_PAD1: { - if(!vflag) - printf(" pad1"); - else - printf("\n\tPad 1"); - } - break; - case MESSAGE_PADN: { if(!vflag) printf(" padN"); diff --git a/tests/babel_pad1.out b/tests/babel_pad1.out index 563ebcb4..c42f2ebf 100644 --- a/tests/babel_pad1.out +++ b/tests/babel_pad1.out @@ -1,2 +1,2 @@ -IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (9) hello [|babel] -IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (60) hello pad1 pad1 [|babel] +IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (9) hello pad1 +IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (60) hello pad1 nh pad1 router-id pad1 update pad1 update pad1