Skip to content

Commit a1ddeb1

Browse files
committed
NTP: Replace the remaining "goto invalid" checks with ND_ICHECK_U()
1 parent dd04b89 commit a1ddeb1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

print-ntp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ ntp_time_print(netdissect_options *ndo,
245245
uint8_t stratum;
246246
u_int efs_len;
247247

248-
if (length < NTP_TIMEMSG_MINLEN)
249-
goto invalid;
248+
ND_ICHECK_U(length, <, NTP_TIMEMSG_MINLEN);
250249

251250
stratum = GET_U_1(bp->stratum);
252251
ND_PRINT(", Stratum %u (%s)",
@@ -369,8 +368,7 @@ ntp_control_print(netdissect_options *ndo,
369368
uint8_t control, R, E, M, opcode;
370369
uint16_t sequence, status, assoc, offset, count;
371370

372-
if (length < NTP_CTRLMSG_MINLEN)
373-
goto invalid;
371+
ND_ICHECK_U(length, <, NTP_CTRLMSG_MINLEN);
374372

375373
control = GET_U_1(cd->control);
376374
R = (control & 0x80) != 0;
@@ -396,8 +394,7 @@ ntp_control_print(netdissect_options *ndo,
396394
count = GET_BE_U_2(cd->count);
397395
ND_PRINT(", Count=%hu", count);
398396

399-
if (NTP_CTRLMSG_MINLEN + count > length)
400-
goto invalid;
397+
ND_ICHECK_U(length, <, NTP_CTRLMSG_MINLEN + count);
401398
if (count != 0) {
402399
ND_TCHECK_LEN(cd->data, count);
403400
ND_PRINT("\n\tTO-BE-DONE: data not interpreted");

0 commit comments

Comments
 (0)