@@ -177,8 +177,7 @@ egpnr_print(netdissect_options *ndo,
177
177
for (gateways = 0 ; gateways < t_gateways ; ++ gateways ) {
178
178
/* Pickup host part of gateway address */
179
179
addr = 0 ;
180
- if (length < 4 - netlen )
181
- goto invalid ;
180
+ ND_ICHECK_U (length , < , 4 - netlen );
182
181
ND_TCHECK_LEN (cp , 4 - netlen );
183
182
switch (netlen ) {
184
183
@@ -197,8 +196,7 @@ egpnr_print(netdissect_options *ndo,
197
196
}
198
197
addr |= net ;
199
198
length -= 4 - netlen ;
200
- if (length < 1 )
201
- goto invalid ;
199
+ ND_ICHECK_U (length , < , 1 );
202
200
distances = GET_U_1 (cp );
203
201
cp ++ ;
204
202
length -- ;
@@ -209,8 +207,7 @@ egpnr_print(netdissect_options *ndo,
209
207
comma = "" ;
210
208
ND_PRINT ("(" );
211
209
while (distances != 0 ) {
212
- if (length < 2 )
213
- goto invalid ;
210
+ ND_ICHECK_U (length , < , 2 );
214
211
ND_PRINT ("%sd%u:" , comma , GET_U_1 (cp ));
215
212
cp ++ ;
216
213
comma = ", " ;
@@ -219,20 +216,17 @@ egpnr_print(netdissect_options *ndo,
219
216
length -= 2 ;
220
217
while (networks != 0 ) {
221
218
/* Pickup network number */
222
- if (length < 1 )
223
- goto invalid ;
219
+ ND_ICHECK_U (length , < , 1 );
224
220
addr = ((uint32_t ) GET_U_1 (cp )) << 24 ;
225
221
cp ++ ;
226
222
length -- ;
227
223
if (IN_CLASSB (addr )) {
228
- if (length < 1 )
229
- goto invalid ;
224
+ ND_ICHECK_U (length , < , 1 );
230
225
addr |= ((uint32_t ) GET_U_1 (cp )) << 16 ;
231
226
cp ++ ;
232
227
length -- ;
233
228
} else if (!IN_CLASSA (addr )) {
234
- if (length < 2 )
235
- goto invalid ;
229
+ ND_ICHECK_U (length , < , 2 );
236
230
addr |= ((uint32_t ) GET_U_1 (cp )) << 16 ;
237
231
cp ++ ;
238
232
addr |= ((uint32_t ) GET_U_1 (cp )) << 8 ;
0 commit comments