Skip to content

Commit 2654afb

Browse files
committed
gre: clean up GRE "version 1" (PPTP) parsing of "key" field.
In the PPTP (RFC 2637) version of the PPTP header, the "key" field, which must be present, consists of a 2-byte big-endian payload length followed by a 2-byte big-endian call ID. Dissect it as such, and report an error if the K bit *isn't* set.
1 parent 96026bd commit 2654afb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

print-gre.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,19 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
348348
len -= 2;
349349
bp += 2;
350350

351-
352351
if (flags & GRE_KP) {
353-
uint32_t k;
352+
/* Skip payload length? */
353+
ND_ICHECK_U(len, <, 2);
354+
ND_TCHECK_LEN(bp, 2);
355+
len -= 2;
356+
bp += 2;
354357

355-
ND_ICHECK_U(len, <, 4);
356-
k = GET_BE_U_4(bp);
357-
ND_PRINT(", call %u", k & 0xffff);
358-
len -= 4;
359-
bp += 4;
360-
}
358+
ND_ICHECK_U(len, <, 2);
359+
ND_PRINT(", call %u", GET_BE_U_2(bp));
360+
len -= 2;
361+
bp += 2;
362+
} else
363+
ND_PRINT(", (ERROR: K flag not set)");
361364

362365
if (flags & GRE_SP) {
363366
ND_ICHECK_U(len, <, 4);

0 commit comments

Comments
 (0)