Skip to content

Commit dd04b89

Browse files
committed
EGP: Replace the remaining "goto invalid" checks with ND_ICHECK_U()
1 parent 42e67bf commit dd04b89

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

print-egp.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ egpnr_print(netdissect_options *ndo,
177177
for (gateways = 0; gateways < t_gateways; ++gateways) {
178178
/* Pickup host part of gateway address */
179179
addr = 0;
180-
if (length < 4 - netlen)
181-
goto invalid;
180+
ND_ICHECK_U(length, <, 4 - netlen);
182181
ND_TCHECK_LEN(cp, 4 - netlen);
183182
switch (netlen) {
184183

@@ -197,8 +196,7 @@ egpnr_print(netdissect_options *ndo,
197196
}
198197
addr |= net;
199198
length -= 4 - netlen;
200-
if (length < 1)
201-
goto invalid;
199+
ND_ICHECK_U(length, <, 1);
202200
distances = GET_U_1(cp);
203201
cp++;
204202
length--;
@@ -209,8 +207,7 @@ egpnr_print(netdissect_options *ndo,
209207
comma = "";
210208
ND_PRINT("(");
211209
while (distances != 0) {
212-
if (length < 2)
213-
goto invalid;
210+
ND_ICHECK_U(length, <, 2);
214211
ND_PRINT("%sd%u:", comma, GET_U_1(cp));
215212
cp++;
216213
comma = ", ";
@@ -219,20 +216,17 @@ egpnr_print(netdissect_options *ndo,
219216
length -= 2;
220217
while (networks != 0) {
221218
/* Pickup network number */
222-
if (length < 1)
223-
goto invalid;
219+
ND_ICHECK_U(length, <, 1);
224220
addr = ((uint32_t) GET_U_1(cp)) << 24;
225221
cp++;
226222
length--;
227223
if (IN_CLASSB(addr)) {
228-
if (length < 1)
229-
goto invalid;
224+
ND_ICHECK_U(length, <, 1);
230225
addr |= ((uint32_t) GET_U_1(cp)) << 16;
231226
cp++;
232227
length--;
233228
} else if (!IN_CLASSA(addr)) {
234-
if (length < 2)
235-
goto invalid;
229+
ND_ICHECK_U(length, <, 2);
236230
addr |= ((uint32_t) GET_U_1(cp)) << 16;
237231
cp++;
238232
addr |= ((uint32_t) GET_U_1(cp)) << 8;

0 commit comments

Comments
 (0)