20
20
21
21
#include <config.h>
22
22
23
- #define ND_LONGJMP_FROM_TCHECK
24
23
#include "netdissect-stdinc.h"
25
24
25
+ #define ND_LONGJMP_FROM_TCHECK
26
26
#include "netdissect.h"
27
27
#include "addrtoname.h"
28
28
#include "extract.h"
@@ -40,21 +40,20 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
40
40
/* See if we think we're at the beginning of a compound packet */
41
41
type = GET_U_1 (sp );
42
42
len = GET_BE_U_2 (sp + 1 );
43
- if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX )
44
- goto trunc ; /* not really truncated, but still not decodable */
43
+ ND_ICHECK_U (len , > , 1500 );
44
+ ND_ICHECK_U (len , < , 3 );
45
+ ND_ICHECK_U (type , = = , 0 );
46
+ ND_ICHECK_U (type , > , MSDP_TYPE_MAX );
45
47
while (length != 0 ) {
46
48
unsigned int entry_count ;
47
49
48
- if (length < 3 )
49
- goto trunc ;
50
+ ND_ICHECK_U (length , < , 3 );
50
51
type = GET_U_1 (sp );
51
52
len = GET_BE_U_2 (sp + 1 );
52
53
if (len > 1400 || ndo -> ndo_vflag )
53
54
ND_PRINT (" [len %u]" , len );
54
- if (len < 3 )
55
- goto trunc ;
56
- if (length < len )
57
- goto trunc ;
55
+ ND_ICHECK_U (len , < , 3 );
56
+ ND_ICHECK_U (length , < , len );
58
57
switch (type ) {
59
58
case 1 : /* IPv4 Source-Active */
60
59
case 3 : /* IPv4 Source-Active Response */
@@ -64,14 +63,12 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
64
63
ND_PRINT (" SA-Response" );
65
64
66
65
/* Entry Count */
67
- if (len < 4 )
68
- goto trunc ;
66
+ ND_ICHECK_U (len , < , 4 );
69
67
entry_count = GET_U_1 (sp + 3 );
70
68
ND_PRINT (" %u entries" , entry_count );
71
69
72
70
/* RP Address */
73
- if (len < 8 )
74
- goto trunc ;
71
+ ND_ICHECK_U (len , < , 8 );
75
72
/* XXX -print this based on ndo_vflag? */
76
73
ND_TCHECK_LEN (sp + 4 , 4 );
77
74
@@ -93,13 +90,11 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
93
90
ND_PRINT (" SA-Request" );
94
91
95
92
/* Reserved */
96
- if (len < 4 )
97
- goto trunc ;
93
+ ND_ICHECK_U (len , < , 4 );
98
94
ND_TCHECK_1 (sp + 3 );
99
95
100
96
/* Group Address */
101
- if (len < 8 )
102
- goto trunc ;
97
+ ND_ICHECK_U (len , < , 8 );
103
98
if (len != 8 )
104
99
ND_PRINT ("[len=%u] " , len );
105
100
ND_PRINT (" for %s" , GET_IPADDR_STRING (sp + 4 ));
@@ -121,6 +116,8 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
121
116
length -= len ;
122
117
}
123
118
return ;
124
- trunc :
125
- nd_print_trunc (ndo );
119
+
120
+ invalid :
121
+ nd_print_invalid (ndo );
122
+
126
123
}
0 commit comments