@@ -54,81 +54,76 @@ static const struct tok fcode_str[] = {
5454
5555static void
5656loopback_message_print (netdissect_options * ndo ,
57- const u_char * cp , u_int len )
57+ const u_char * cp , u_int length )
5858{
5959 uint16_t function ;
6060
61- if (len < 2 )
62- goto invalid ;
61+ ND_ICHECK_U (length , < , 2 );
6362 /* function */
6463 function = GET_LE_U_2 (cp );
6564 cp += 2 ;
66- len -= 2 ;
65+ length -= 2 ;
6766 ND_PRINT (", %s" , tok2str (fcode_str , " invalid (%u)" , function ));
6867
6968 switch (function ) {
7069 case LOOPBACK_REPLY :
71- if (len < 2 )
72- goto invalid ;
70+ ND_ICHECK_U (length , < , 2 );
7371 /* receipt number */
7472 ND_PRINT (", receipt number %u" , GET_LE_U_2 (cp ));
7573 cp += 2 ;
76- len -= 2 ;
74+ length -= 2 ;
7775 /* data */
78- ND_PRINT (", data (%u octets)" , len );
79- ND_TCHECK_LEN (cp , len );
76+ ND_PRINT (", data (%u octets)" , length );
77+ ND_TCHECK_LEN (cp , length );
8078 break ;
8179 case LOOPBACK_FWDDATA :
82- if (len < MAC48_LEN )
83- goto invalid ;
80+ ND_ICHECK_U (length , < , MAC48_LEN );
8481 /* forwarding address */
8582 ND_PRINT (", forwarding address %s" , GET_MAC48_STRING (cp ));
8683 cp += MAC48_LEN ;
87- len -= MAC48_LEN ;
84+ length -= MAC48_LEN ;
8885 /* data */
89- ND_PRINT (", data (%u octets)" , len );
90- ND_TCHECK_LEN (cp , len );
86+ ND_PRINT (", data (%u octets)" , length );
87+ ND_TCHECK_LEN (cp , length );
9188 break ;
9289 default :
93- ND_TCHECK_LEN (cp , len );
90+ ND_TCHECK_LEN (cp , length );
9491 break ;
9592 }
9693 return ;
9794
9895invalid :
9996 nd_print_invalid (ndo );
100- ND_TCHECK_LEN (cp , len );
97+ ND_TCHECK_LEN (cp , length );
10198}
10299
103100void
104101loopback_print (netdissect_options * ndo ,
105- const u_char * cp , u_int len )
102+ const u_char * cp , u_int length )
106103{
107104 uint16_t skipCount ;
108105
109106 ndo -> ndo_protocol = "loopback" ;
110107 ND_PRINT ("Loopback" );
111- if (len < 2 )
112- goto invalid ;
108+ ND_ICHECK_U (length , < , 2 );
113109 /* skipCount */
114110 skipCount = GET_LE_U_2 (cp );
115111 cp += 2 ;
116- len -= 2 ;
112+ length -= 2 ;
117113 ND_PRINT (", skipCount %u" , skipCount );
118114 if (skipCount % 8 )
119115 ND_PRINT (" (bogus)" );
120- if (skipCount > len )
121- goto invalid ;
116+ ND_ICHECK_U (length , < , skipCount );
122117 /* the octets to skip */
123118 ND_TCHECK_LEN (cp , skipCount );
124119 cp += skipCount ;
125- len -= skipCount ;
120+ length -= skipCount ;
126121 /* the first message to decode */
127- loopback_message_print (ndo , cp , len );
122+ loopback_message_print (ndo , cp , length );
128123 return ;
129124
130125invalid :
131126 nd_print_invalid (ndo );
132- ND_TCHECK_LEN (cp , len );
127+ ND_TCHECK_LEN (cp , length );
133128}
134129
0 commit comments