Skip to content

Commit 05a263a

Browse files
committed
LISP: Add a length check
Verify we have at least the header length. Print the protocol name with nd_print_protocol_caps() before any check. Update the lisp_type[] structure accordingly. Add a test file with an invalid length.
1 parent 9aee996 commit 05a263a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

print-lisp.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ enum {
128128
};
129129

130130
static const struct tok lisp_type [] = {
131-
{ 0, "LISP-Reserved" },
132-
{ 1, "LISP-Map-Request" },
133-
{ 2, "LISP-Map-Reply" },
134-
{ 3, "LISP-Map-Register" },
135-
{ 4, "LISP-Map-Notify" },
136-
{ 8, "LISP-Encapsulated-Control-Message" },
131+
{ 0, "Reserved" },
132+
{ 1, "Map-Request" },
133+
{ 2, "Map-Reply" },
134+
{ 3, "Map-Register" },
135+
{ 4, "Map-Notify" },
136+
{ 8, "Encapsulated-Control-Message" },
137137
{ 0, NULL }
138138
};
139139

@@ -245,6 +245,8 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
245245
const lisp_map_register_loc *lisp_loc;
246246

247247
ndo->ndo_protocol = "lisp";
248+
nd_print_protocol_caps(ndo);
249+
ND_ICHECK_ZU(length, <, MAP_REGISTER_HDR_LEN);
248250
lisp_hdr = (const lisp_map_register_hdr *) bp;
249251
lisp_hdr_flag(ndo, lisp_hdr);
250252
/* Supporting only MAP NOTIFY and MAP REGISTER LISP packets */
@@ -406,7 +408,7 @@ static void lisp_hdr_flag(netdissect_options *ndo, const lisp_map_register_hdr *
406408
{
407409
uint8_t type = extract_lisp_type(GET_U_1(lisp_hdr->type_and_flag));
408410

409-
ND_PRINT("%s,", tok2str(lisp_type, "unknown-type-%u", type));
411+
ND_PRINT("-%s,", tok2str(lisp_type, "unknown-type-%u", type));
410412
if (!ndo->ndo_vflag)
411413
return;
412414

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ lisp_eid_register-v lisp_eid_register.pcap lisp_eid_register-v.out -v
563563
lisp_ipv6_eid-v lisp_ipv6.pcap lisp_ipv6-v.out -v
564564
lisp_invalid lisp_invalid.pcap lisp_invalid.out
565565
lisp_invalid-v lisp_invalid.pcap lisp_invalid-v.out -v
566+
lisp_invalid_lengths lisp_invalid_length.pcap lisp_invalid_length.out
566567

567568
# NSH tests
568569
nsh nsh.pcap nsh.out

tests/lisp_invalid_length.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 1970-01-15 05:20:00.049333 IP 13.1.1.1.61 > 1.254.1.121.4342: LISP [length 8 < 16] (invalid)

tests/lisp_invalid_length.pcap

149 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)